{"id":5797,"date":"2021-06-16T14:02:56","date_gmt":"2021-06-16T06:02:56","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=5797"},"modified":"2021-06-16T14:02:56","modified_gmt":"2021-06-16T06:02:56","slug":"inceptor%e8%8e%b7%e5%8f%96%e6%89%a7%e8%a1%8c%e8%ae%a1%e5%88%92","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=5797","title":{"rendered":"inceptor\u83b7\u53d6\u6267\u884c\u8ba1\u5212"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p><strong>\u4ec0\u4e48\u662f\u6267\u884c\u8ba1\u5212\uff1f<\/strong><\/p>\n<p>\u6240\u8c13\u6267\u884c\u8ba1\u5212\uff0c\u901a\u4fd7\u70b9\u8bf4\u5c31\u662f\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5668\u5728\u6267\u884csql\u8bed\u53e5\u7684\u65f6\u5019\uff0c\u4f1a\u51c6\u5907\u51e0\u5957\u65b9\u6848\uff0c\u6700\u540e\u9009\u62e9\u6d88\u8017\u8d44\u6e90\u6700\u5c0f\u7684\u90a3\u4e2a\u65b9\u6848\u3002\u8fd9\u5c31\u662f\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<p>\u5bf9\u4e8esql\u800c\u8a00\uff0c\u6211\u4eec\u4ec5\u4ec5\u662f\u63cf\u8ff0\u51fasql\u7684\u52a8\u4f5c\uff0c\u81f3\u4e8e\u5982\u4f55\u6267\u884c\uff0c\u662f\u7531\u6570\u636e\u5e93\u6765\u51b3\u5b9a\u7684\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p><strong>\u5982\u4f55\u83b7\u53d6\u6267\u884c\u8ba1\u5212\uff1f<\/strong><\/p>\n<pre><code class=\"language-sql\">-- \u4f7f\u7528\u8bed\u6cd5\nEXPLAIN [COST|FORMATTED|EXTENDED|DEPENDENCY] hql_query<\/code><\/pre>\n<p>\u76f8\u6bd4\u6765\u8bf4<strong><code>EXPLAIN<\/code>\u548c<code>EXPLAIN COST<\/code><\/strong>\u8fd9\u4e24\u4e2a\u8f83\u4e3a\u5e38\u7528\u3002<\/p>\n<p>\u4ee5\u4e0b\u9762\u7684\u8bed\u53e5\u4e3a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-sql\">EXPLAIN\nINSERT OVERWRITE TABLE \n    access_log_temp2\nselect \n    a.<code>USER<\/code>,\n    a.prono,\n    p.maker,\n    p.price\nFROM \n    access_log_hbase a \nJOIN \n    product_hbase p \n    ON (a.prono = p.prono);<\/code><\/pre>\n<h3>\u6267\u884c\u8ba1\u5212\u5305\u542b\u54ea\u4e9b\u5185\u5bb9\uff1f<\/h3>\n<pre><code class=\"language-ruby\">\u00b7 The Abstract Syntax Tree for the query\n\u00b7 The dependencies between the different stages of the plan\n\u00b7 The specific description of each of the stages<\/code><\/pre>\n<h3>\u5982\u4f55\u5206\u6790\u6267\u884c\u8ba1\u5212\uff1f<\/h3>\n<p>\u5206\u6790\u987a\u5e8f\uff1a\u4ece\u4e0b\u81f3\u4e0a<\/p>\n<pre><code class=\"language-sql\">-- explain cost \u6267\u884c\u7ed3\u679c\nINCEPTOR QUERY PLAN #0:\n  **FileSinkOperator\n    **SelectOperator\n      **JoinOperator (No numRows)\n          non-Cumulative-Cost: No estimation; CumulativeCost: No estimation;\n        **ReduceSinkOperator\n          **TableScanOperator (table name: default.access_log_hbase; alias: a)\n        **ReduceSinkOperator\n          **TableScanOperator (table name: default.product_hbase; alias: p)\n\nNote: CBO failed, due to: \nnull<\/code><\/pre>\n<pre><code class=\"language-sql\">-- explain \u6267\u884c\u7ed3\u679c\nABSTRACT SYNTAX TREE:\n  (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_TABREF (TOK_TABNAME access_log_hbase) a) (TOK_TABREF (TOK_TABNAME product_hbase) p) (= (. (TOK_TABLE_OR_COL a) prono) (. (TOK_TABLE_OR_COL p) prono)))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME access_log_temp2))) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL a) <code>USER<\/code>)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL a) prono)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL p) maker)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL p) price)))))\n\nSTAGE DEPENDENCIES:\n  Stage-0 is a root stage [MAPRED]\n  Stage-1 depends on stages: Stage-0 [MOVE]\n\nSTAGE PLANS:\n  Stage: Stage-0\n\n  Stage: Stage-1\n    Move Operator\n      tables:\n          replace: true\n          table:\n              input format: org.apache.hadoop.mapred.TextInputFormat\n              output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat\n              serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe\n              name: default.access_log_temp2\n\nINCEPTOR QUERY PLAN #0:\n  **io.transwarp.inceptor.execution.FileSinkOperator       **************************\n  File Output Operator\n    compressed: false                                      #\u8868\u793a\u6587\u4ef6\u8f93\u51fa\u7684\u7ed3\u679c\u662f\u5426\u8fdb\u884c\u538b\u7f29\uff0cfalse\u8868\u793a\u4e0d\u8fdb\u884c\u8f93\u51fa\u538b\u7f29\n    GlobalTableId: 1\n    table:\n        input format: org.apache.hadoop.mapred.TextInputFormat   #\u5206\u522b\u8868\u793a\u6587\u4ef6\u8f93\u5165\u548c\u8f93\u51fa\u7684\u6587\u4ef6\u7c7b\u578b\n        output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat\n        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe #\u8868\u793a\u8bfb\u53d6\u8868\u6570\u636e\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u65b9\u5f0f\n        name: default.access_log_temp2\n    **io.transwarp.inceptor.execution.SelectOperator       **************************\n    Select Operator\n      expressions:                                         #\u8868\u793a\u9700\u8981\u7b5b\u9009\u7684\u5217\n            expr: _col1\n            type: string\n            expr: _col0\n            type: int\n            expr: _col9\n            type: int\n            expr: _col10\n            type: int\n      outputColumnNames: _col0, _col1, _col2, _col3        #\u8868\u793a\u8f93\u51fa\u7684\u5217\u540d\n      **io.transwarp.inceptor.execution.JoinOperator       **************************\n      Join Operator\n        condition map:\n             Inner Join 0 to 1                             #\u8868\u793ajoin\u7684\u7c7b\u578b\uff0c\u8fd9\u91cc\u662f\u5185\u8fde\u63a5\n        join expressions:\n          0 [Column[VALUE._col0], Column[VALUE._col1]]\n          1 [Column[VALUE._col1], Column[VALUE._col2]]\n        condition expressions:                             #\u8868\u793ajoin\u4e2d\u4e24\u8868\u5206\u522b\u5305\u542b\u7684\u5b57\u6bb5\n          0 {VALUE._col0} {VALUE._col1}\n          1 {VALUE._col1} {VALUE._col2}\n        handleSkewJoin: false:                             #inceptor\u4e2d\u9ed8\u8ba4\u662ffalse(set hive.optimize.skewjoin)\u5728\u5f00\u542f\u65f6\uff0c\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u626b\u63cf\u5e76\u76d1\u6d4b\u54ea\u4e2akey\u4f1a\u51fa\u73b0\u503e\u659c\uff0c\u5bf9\u4e8e\u503e\u659c\u7684key\uff0c\u7528map join\u5904\u7406\uff0c\u4e0d\u503e\u659c\u7684key\u6b63\u5e38\u5904\u7406\n        outputColumnNames: _col0, _col1, _col9, _col10\n        **io.transwarp.inceptor.execution.ReduceSinkOperator  **************************\n        Reduce Output Operator\n          key expressions: prono (type: int)               #RS\u7ec4\u5408\u5b57\u6bb5\u4e4bkey expression\n          sort order: +                                    #\u6309\u7167prono\u6b63\u6392\n          Map-reduce partition columns: prono (type: int)  #\u6309\u7167prono\u6c42hash\u503c\u5206\u914dreduce\n          value expressions: prono (type: int), user (type: string)  #RS\u7ec4\u5408\u5b57\u6bb5\u4e4bvalue expression\n          **io.transwarp.inceptor.execution.FilterOperator **************************\n          Filter Operator\n            predicate:\n                expr: prono is not null\n                type: boolean\n            error forward: false\n            error tolerant: false\n            **io.transwarp.inceptor.execution.TableScanOperator    **************************\n            TableScan\n              alias: a\n        **io.transwarp.inceptor.execution.ReduceSinkOperator       **************************\n        Reduce Output Operator                             #\u8fd9\u91cc\u63cf\u8ff0map\u7684\u8f93\u51fa\uff0c\u4e5f\u5c31\u662freduce\u7684\u8f93\u5165\u3002\u6bd4\u5982key\uff0cpartition\uff0csort\u7b49\u4fe1\u606f\n          key expressions: prono (type: int)               #reduce job\u7684key\n          sort order: +                                    #\u8fd9\u91cc\u8868\u793a\u6309\u4e00\u4e2a\u5b57\u6bb5\u6392\u5e8f\uff0c\u5982\u679c\u662f\u6309\u4e24\u4e2a\u5b57\u6bb5\u6392\u5e8f\uff0c\u90a3\u4e48\u5c31\u4f1a\u6709\u4e24\u4e2a+(++),\u66f4\u591a\u4ee5\u6b64\u7c7b\u63a8\n          Map-reduce partition columns: prono (type: int)  #partition\u7684\u4fe1\u606f\uff0c\u7531\u6b64\u4e5f\u53ef\u4ee5\u770b\u51fahive\u5728join\u7684\u65f6\u5019\u4f1a\u4ee5join on\u540e\u7684\u5217\u4f5c\u4e3apartition\u7684\u5217\uff0c\u4ee5\u4fdd\u8bc1\u5177\u6709\u76f8\u540c\u6b64\u5217\u7684\u503c\u7684\u884c\u88ab\u5206\u5230\u540c\u4e00\u4e2areduce\u4e2d\u53bb\n          value expressions: maker (type: int), price (type: int)\n          **io.transwarp.inceptor.execution.FilterOperator          **************************\n          Filter Operator\n            predicate:\n                expr: prono is not null\n                type: boolean\n            error forward: false\n            error tolerant: false\n            **io.transwarp.inceptor.execution.TableScanOperator     **************************\n            TableScan\n              alias: p<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u4ec0\u4e48\u662f\u6267\u884c\u8ba1\u5212\uff1f \u6240\u8c13\u6267\u884c\u8ba1\u5212\uff0c\u901a\u4fd7\u70b9\u8bf4\u5c31\u662f\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5668\u5728\u6267\u884csql\u8bed\u53e5\u7684\u65f6\u5019\uff0c\u4f1a\u51c6\u5907\u51e0\u5957\u65b9\u6848\uff0c\u6700 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=5797\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121],"tags":[],"class_list":["post-5797","post","type-post","status-publish","format-standard","hentry","category-121"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/5797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5797"}],"version-history":[{"count":1,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/5797\/revisions"}],"predecessor-version":[{"id":6043,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/5797\/revisions\/6043"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}