{"id":1890,"date":"2020-10-02T17:08:24","date_gmt":"2020-10-02T09:08:24","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=1890"},"modified":"2020-10-02T17:08:23","modified_gmt":"2020-10-02T09:08:23","slug":"%e6%b5%81%e8%a1%a8join%e5%a4%a7%e6%b3%95%e4%b9%8b-glkjoin","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=1890","title":{"rendered":"\u6d41\u8868join\u5927\u6cd5\u4e4b-glkjoin"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>\u672c\u6587\u65e8\u5728\u8bb2\u89e3\u6d41\u8868join\u7684glkjoin\u4f7f\u7528\u65b9\u6cd5<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p>Glkjoin\u662f\u6700\u4e3a\u63a8\u8350\u7684\u6d41\u8868join\u65b9\u6cd5\uff0c\u9002\u5408\u4e8e\u5927\u8868join\u3002\u53ea\u652f\u6301hyperdrive\u548ces\u8868\u3002<\/p>\n<h4>hyperdrive\u8868\uff1a<\/h4>\n<p>\u6d4b\u8bd5\u7528\u4f8b\uff1a<br \/>\n1.\u672a\u5f00\u5b89\u5168<\/p>\n<pre><code class=\"language-sql\">\u5f00\u542f\u4e8b\u4ef6\u6a21\u5f0f\nSET streamsql.use.eventmode=true;\n\u4e8b\u4ef6\u6a21\u5f0f\u4e0b\u81ea\u52a8flush\u6570\u636e\nSET morphling.result.auto.flush=true;\n\n\u5efa\u6d41\nDROP STREAM IF EXISTS test_stream;\nCREATE STREAM test_stream(id INT, letter STRING)\nROW FORMAT DELIMITED FIELDS TERMINATED BY ','\nTBLPROPERTIES(\"topic\"=\"jane\",\"kafka.zookeeper\"=\"172.22.39.7:2181,\",\"kafka.broker.list\"=\"172.22.39.7:9092\");\nDROP TABLE IF EXISTS test_hyperbase;\n\n\u5efa\u8868\nCREATE TABLE test_hyperbase(id INT, letter STRING)\n STORED AS HYPERDRIVE;\nDROP STREAMJOB test_streamJob;\n\n\u521b\u5efastreamjob\uff0c\u8be5streamjob\u5c06\u6d41\u548c\u8868\u7684letter\u5b57\u6bb5\u8fdb\u884c\u62fc\u63a5\u540e\u63d2\u5165\u8868test_hyperbase\nCREATE STREAMJOB test_streamJob AS (\"\n    INSERT INTO test_hyperbase\n    SELECT \/* +glkjoin(b) *\/ a.id,concat(a.letter, b.letter)\n    FROM test_stream a\n    LEFT JOIN test_hyperbase b\n    ON a.id = b.id\n    \");\n\n\u5f00\u542fstreamjob\nSTART STREAMJOB test_streamJob;\nLIST STREAMJOBS;\nSELECT * FROM test_hyperbase;\nSTOP STREAMJOB test_streamjob;\n<\/code><\/pre>\n<p>\u751f\u4ea7\u8005\u6570\u636e\uff1a<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256340944.png\" alt=\"file\" \/><\/p>\n<p>\u7ed3\u679c\u8868\uff1a<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/02\/image-1592273534313.png\" alt=\"file\" \/><\/p>\n<p>2.\u5f00\u542f\u5b89\u5168<br \/>\n\u5f00\u542f\u5b89\u5168\u548c\u672a\u5f00\u5b89\u5168\u7684\u4e3b\u8981\u533a\u522b\u5c31\u662f\u5efa\u6d41\u65b9\u5f0f\u4e0d\u540c<\/p>\n<p>\u5efa\u6d41<\/p>\n<pre><code class=\"language-sql\">\n\u5efa\u6d41\nDROP STREAM test_stream1;\nCREATE STREAM test_stream1(id INT, letter STRING)\n  ROW FORMAT DELIMITED FIELDS TERMINATED BY ','\n  TBLPROPERTIES(\"topic\"=\"demoo\",\n  \"kafka.zookeeper\"=\"172.22.22.1:2181\",\n  \"kafka.broker.list\"=\"172.22.22.1:9092\",\n  \"transwarp.consumer.security.protocol\"=\"SASL_PLAINTEXT\",\n  \"transwarp.consumer.sasl.kerberos.service.name\"=\"kafka\",\n  \"transwarp.consumer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\\\"\/etc\/slipstream1\/conf\/xmyh.keytab\\\" principal=\\\"xmyh@TDH\\\"\"\n  );\n\n  \u5efa\u8868\nDROP TABLE IF EXISTS test_hyperbase;\nCREATE TABLE test_hyperbase(id INT, letter STRING)\nSTORED AS HYPERDRIVE;\n\n\u521b\u5efa\u884d\u751f\u6d41\uff0c\u6b64\u5904\u884d\u751f\u6d41\u7684\u4f5c\u7528\u662f\u5c06\u8868\u548c\u6d41\u7684\u5b57\u6bb5\u8fdb\u884c\u62fc\u63a5\nCREATE STREAM s3 AS\nSELECT \/* +glkjoin(b) *\/ a.id,concat(a.letter, b.letter)\nFROM test_stream1 a\nLEFT join test_hyperbase b \nON a.id = b.id;\n\n\u8bbe\u7f6eglkjoin\u7684batchsize\nset stargate.global.lookup.join.batchsize=1;\n\n\u542f\u52a8job\uff0c\u5c06\u884d\u751f\u6d41\u6570\u636e\u63d2\u5165\u8868test_hyperbase\nINSERT INTO test_hyperbase SELECT * FROM s3;\nSELECT * FROM test_hyperbase;<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256459149.png\" alt=\"file\" \/><\/p>\n<h4>ES\u8868\uff1a<\/h4>\n<p>\u6d4b\u8bd5\u7528\u4f8b\uff1a<\/p>\n<p>1.\u672a\u5f00\u5b89\u5168<\/p>\n<pre><code class=\"language-sql\">\u5efa\u6d41\nDROP STREAM test_stream;\nCREATE STREAM test_stream(id string, letter STRING)\nROW FORMAT DELIMITED FIELDS TERMINATED BY ','\nTBLPROPERTIES(\"topic\"=\"jane\",\"kafka.zookeeper\"=\"172.22.39.7:2181,\",\"kafka.broker.list\"=\"172.22.39.7:9092\");\n\n\u521b\u5efa\u8fc7\u6e21\u8868t1\nDROP TABLE t1;\nCREATE TABLE t1 (id STRING, letter STRING) stored as ES with shard number 8 replication 1;\n\n\u521b\u5efastreamjob\uff0c\u628a\u6d41\u6570\u636e\u63d2\u5165\u8868t1\nCREATE STREAMJOB sb AS (\"INSERT INTO t1 SELECT * FROM test_stream\");\nSTART STREAMJOB sb;\nSELECT * FROM t1;\n\n\u5efa\u8868tab\nCREATE TABLE tab (id STRING, letter STRING) stored as ES with shard number 8 replication 1;\n\n\u5efa\u6d41test_stream2\nCREATE STREAM test_stream2(id string, letter STRING)\nROW FORMAT DELIMITED FIELDS TERMINATED BY ','\nTBLPROPERTIES(\"topic\"=\"jane\",\"kafka.zookeeper\"=\"172.22.39.7:2181,\",\"kafka.broker.list\"=\"172.22.39.7:9092\");\n\n\u521b\u5efastreamjob\uff0c\u5c06test_stream2\u6570\u636e\u63d2\u5165\u8868tab\nCREATE STREAMJOB 2job AS (\"insert into tab select * from test_stream2\");\nSTART STREAMJOB 2job;\nSELECT * FROM tab;\nDROP STREAMJOB 2job;\nDROP STREAM s3;\n\n\u521b\u5efa\u884d\u751f\u6d41s3\uff0c\u505aGlkjoin\nCREATE STREAM s3 AS\nSELECT \/* +glkjoin(b) *\/ a.id,concat(a.letter, b.letter)\nFROM test_stream a\njoin tab b \nON a.id = b.id;\n\n\u5efa\u8868t8\nDROP TABLE t8;\nCREATE TABLE t8 (id STRING, letter STRING) stored as ES with shard number 8 replication 1;\n\n\u5efa\u7a97\u53e3\u6d41s2_join\nDROP STREAM s2_join;\nCREATE STREAM s2_join as SELECT * FROM s3 STREAMWINDOW w1 AS\n(INTERVAL '1' SECOND);\n\n\u5efastreamjob\u3002\u628a\u7a97\u53e3\u6d41\u6570\u636e\u63d2\u5165\u8868t8\nCREATE STREAMJOB test_streamJob AS (\"insert into t8 select * from s2_join\");\nSTART STREAMJOB test_streamJob;\nLIST STREAMJOBS;\nDROP STREAMJOB test_streamJob;\nSELECT * FROM t8;\nSTOP STREAMJOB test_streamJob;\n<\/code><\/pre>\n<p>\u751f\u4ea7\u8005\u6570\u636e\uff1a<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256628790.png\" alt=\"file\" \/><br \/>\n\u7ed3\u679c\u8868\uff1a<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256650731.png\" alt=\"file\" \/><\/p>\n<p>2.\u5f00\u542f\u5b89\u5168<\/p>\n<pre><code class=\"language-sql\">\u5efa\u6d41\nDROP STREAM test_stream;\nCREATE STREAM test_stream(id string, letter STRING)\n  ROW FORMAT DELIMITED FIELDS TERMINATED BY ','\n  TBLPROPERTIES(\"topic\"=\"demoo\",\n  \"kafka.zookeeper\"=\"172.22.22.1:2181\",\n  \"kafka.broker.list\"=\"172.22.22.1:9092\",\n  \"transwarp.consumer.security.protocol\"=\"SASL_PLAINTEXT\",\n  \"transwarp.consumer.sasl.kerberos.service.name\"=\"kafka\",\n  \"transwarp.consumer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\\\"\/etc\/slipstream1\/conf\/xmyh.keytab\\\" principal=\\\"xmyh@TDH\\\"\"\n  );\n\n \u5efa\u8868\nDROP TABLE t1;\nCREATE TABLE t1 (id STRING, letter STRING) stored as ES with shard number 8 replication 1;\n\n\u5f00\u542fstreamjob\nCREATE STREAMJOB sb AS (\"INSERT INTO t1 SELECT * FROM test_stream\");\nSTART STREAMJOB sb;\nSELECT * FROM t1;\nDROP streamjob sb;\n\n\u5efa\u8868tab\nDROP TABLE IF EXISTS tab;\nCREATE TABLE tab (id STRING, letter STRING) stored as ES with shard number 8 replication 1;\n\n\u5efa\u6d41test_stream2\nCREATE STREAM test_stream2(id string, letter STRING)\n  ROW FORMAT DELIMITED FIELDS TERMINATED BY ','\n  TBLPROPERTIES(\"topic\"=\"demoo\",\n  \"kafka.zookeeper\"=\"172.22.22.1:2181\",\n  \"kafka.broker.list\"=\"172.22.22.1:9092\",\n  \"transwarp.consumer.security.protocol\"=\"SASL_PLAINTEXT\",\n  \"transwarp.consumer.sasl.kerberos.service.name\"=\"kafka\",\n  \"transwarp.consumer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\\\"\/etc\/slipstream1\/conf\/xmyh.keytab\\\" principal=\\\"xmyh@TDH\\\"\"\n  );\n\n \u5f00\u542fstreamjob\nCREATE STREAMJOB 2job AS (\"insert into tab select * from test_stream2\");\nSTART STREAMJOB 2job;\nSELECT * FROM tab;\nDROP STREAMJOB 2job;\n\n\u521b\u5efaglkjoin\u884d\u751f\u6d41s3\nDROP STREAM s3;\nCREATE STREAM s3 AS\nSELECT \/* +glkjoin(b) *\/ a.id,concat(a.letter, b.letter)\nFROM test_stream a\njoin tab b \nON a.id = b.id;\n\n\u5efa\u8868t8\nDROP TABLE t8;\nCREATE TABLE t8 (id STRING, letter STRING) stored as ES with shard number 8 replication 1;\n\n\u5f00\u542fstreamjob\nCREATE STREAMJOB test_streamJob AS (\"insert into t8 select * from s3\");\nSTART STREAMJOB test_streamJob;\nLIST STREAMJOBS;\nDROP STREAMJOB test_streamJob;\nSELECT * FROM t8;\nSTOP STREAMJOB test_streamJob;\n<\/code><\/pre>\n<p>\u4e2d\u95f4\u8868\u6570\u636e\uff1a<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256727897.png\" alt=\"file\" \/><br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256739445.png\" alt=\"file\" \/><\/p>\n<p>\u751f\u4ea7\u8005\u6570\u636e\uff1a<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256750935.png\" alt=\"file\" \/><\/p>\n<p>\u7ed3\u679c\u8868\u6570\u636e\uff1a<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2019\/12\/image-1577256756483.png\" alt=\"file\" \/><\/p>\n<p>\u6ce8\uff1a<\/p>\n<p>\u5982\u9047\u5230\u65e5\u5fd7\u62a5\u9519\uff1a<\/p>\n<pre><code class=\"language-sql\">2019-12-19 15:24:34,836 WARN  execution.GlobalLookupJoinOperator: (Logging.scala:logWarning(71)) [HiveServer2-Handler-Pool: Thread-164(SessionHandle=3a45dafc-26b8-400e-a966-fd27c623a2ee)] - This RSOp with the table [tab]contains the column which can not enable global lookup join: class org.apache.hadoop.hive.ql.udf.generic.GenericUDFToDecimal(Column[id]()<\/code><\/pre>\n<p>\u6ce8\u610fes\u8868\u7b2c\u4e00\u5217\u5fc5\u987b\u662fstring\uff0c\u6240\u4ee5stream\u7684\u7b2c\u4e00\u5217\u4e5f\u662fstring\uff0c\u5426\u5219\u4f1a\u6709\u8fd9\u79cd\u5b57\u6bb5\u7c7b\u578b\u62a5\u9519\u4ea7\u751f<\/p>\n<p>\u6ce8\uff1akafka\u751f\u4ea7\u6d88\u8d39\u6570\u636e\u4f7f\u7528\u547d\u4ee4\u53ef\u4ee5\u53c2\u8003\uff1a<br \/>\n<a href=\"https:\/\/nj.transwarp.cn:8180\/wp-admin\/post.php?post=2543&action=edit\" title=\"kafka\u751f\u4ea7\u6d88\u8d39\u6570\u636e\">kafka\u751f\u4ea7\u6d88\u8d39\u6570\u636e<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u672c\u6587\u65e8\u5728\u8bb2\u89e3\u6d41\u8868join\u7684glkjoin\u4f7f\u7528\u65b9\u6cd5 \u8be6\u7ec6\u8bf4\u660e Glkjoin\u662f\u6700\u4e3a\u63a8\u8350\u7684\u6d41\u8868join\u65b9 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=1890\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1890","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/1890","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\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1890"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/1890\/revisions"}],"predecessor-version":[{"id":3338,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/1890\/revisions\/3338"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}