Saving all output to "!!{outputDirectory}!!/skewjoinopt15.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/skewjoinopt15.q >>> set hive.internal.ddl.list.bucketing.enable=true; No rows affected >>> set hive.optimize.skewjoin.compiletime = true; No rows affected >>> >>> CREATE TABLE tmpT1(key STRING, val STRING) STORED AS TEXTFILE; No rows affected >>> >>> LOAD DATA LOCAL INPATH '../data/files/T1.txt' INTO TABLE tmpT1; No rows affected >>> >>> -- testing skew on other data types - int >>> CREATE TABLE T1(key INT, val STRING) SKEWED BY (key) ON ((2)); No rows affected >>> INSERT OVERWRITE TABLE T1 SELECT key, val FROM tmpT1; '_col0','_col1' No rows selected >>> >>> CREATE TABLE tmpT2(key STRING, val STRING) STORED AS TEXTFILE; No rows affected >>> >>> LOAD DATA LOCAL INPATH '../data/files/T2.txt' INTO TABLE tmpT2; No rows affected >>> >>> CREATE TABLE T2(key INT, val STRING) SKEWED BY (key) ON ((3)); No rows affected >>> >>> INSERT OVERWRITE TABLE T2 SELECT key, val FROM tmpT2; '_col0','_col1' No rows selected >>> >>> -- The skewed key is a integer column. >>> -- Otherwise this test is similar to skewjoinopt1.q >>> -- Both the joined tables are skewed, and the joined column >>> -- is an integer >>> -- adding a order by at the end to make the results deterministic >>> >>> EXPLAIN SELECT a.*, b.* FROM T1 a JOIN T2 b ON a.key = b.key; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_TABREF (TOK_TABNAME T1) a) (TOK_TABREF (TOK_TABNAME T2) b) (= (. (TOK_TABLE_OR_COL a) key) (. (TOK_TABLE_OR_COL b) key)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_ALLCOLREF (TOK_TABNAME a))) (TOK_SELEXPR (TOK_ALLCOLREF (TOK_TABNAME b))))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-2 depends on stages: Stage-1, Stage-4' ' Stage-4 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' subquery1:a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' subquery1:b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Inner Join 0 to 1' ' condition expressions:' ' 0 {VALUE._col0} {VALUE._col1}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col1, _col4, _col5' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: string' ' expr: _col4' ' type: int' ' expr: _col5' ' type: string' ' outputColumnNames: _col0, _col1, _col2, _col3' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' '' ' Stage: Stage-4' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Inner Join 0 to 1' ' condition expressions:' ' 0 {VALUE._col0} {VALUE._col1}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col1, _col4, _col5' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: string' ' expr: _col4' ' type: int' ' expr: _col5' ' type: string' ' outputColumnNames: _col0, _col1, _col2, _col3' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-0' ' Fetch Operator' ' limit: -1' '' '' 185 rows selected >>> >>> SELECT a.*, b.* FROM T1 a JOIN T2 b ON a.key = b.key ORDER BY a.key, b.key, a.val, b.val; 'key','val','key','val' '2','12','2','22' '3','13','3','13' '8','18','8','18' '8','18','8','18' '8','28','8','18' '8','28','8','18' 6 rows selected >>> >>> -- test outer joins also >>> >>> EXPLAIN SELECT a.*, b.* FROM T1 a RIGHT OUTER JOIN T2 b ON a.key = b.key; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_RIGHTOUTERJOIN (TOK_TABREF (TOK_TABNAME T1) a) (TOK_TABREF (TOK_TABNAME T2) b) (= (. (TOK_TABLE_OR_COL a) key) (. (TOK_TABLE_OR_COL b) key)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_ALLCOLREF (TOK_TABNAME a))) (TOK_SELEXPR (TOK_ALLCOLREF (TOK_TABNAME b))))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-2 depends on stages: Stage-1, Stage-4' ' Stage-4 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' subquery1:a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' subquery1:b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Right Outer Join0 to 1' ' condition expressions:' ' 0 {VALUE._col0} {VALUE._col1}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col1, _col4, _col5' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: string' ' expr: _col4' ' type: int' ' expr: _col5' ' type: string' ' outputColumnNames: _col0, _col1, _col2, _col3' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' '' ' Stage: Stage-4' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' value expressions:' ' expr: key' ' type: int' ' expr: val' ' type: string' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Right Outer Join0 to 1' ' condition expressions:' ' 0 {VALUE._col0} {VALUE._col1}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col1, _col4, _col5' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: string' ' expr: _col4' ' type: int' ' expr: _col5' ' type: string' ' outputColumnNames: _col0, _col1, _col2, _col3' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-0' ' Fetch Operator' ' limit: -1' '' '' 185 rows selected >>> >>> SELECT a.*, b.* FROM T1 a RIGHT OUTER JOIN T2 b ON a.key = b.key ORDER BY a.key, b.key, a.val, b.val; 'key','val','key','val' '','','4','14' '','','5','15' '2','12','2','22' '3','13','3','13' '8','18','8','18' '8','18','8','18' '8','28','8','18' '8','28','8','18' 8 rows selected >>> >>> -- an aggregation at the end should not change anything >>> >>> EXPLAIN SELECT count(1) FROM T1 a JOIN T2 b ON a.key = b.key; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_TABREF (TOK_TABNAME T1) a) (TOK_TABREF (TOK_TABNAME T2) b) (= (. (TOK_TABLE_OR_COL a) key) (. (TOK_TABLE_OR_COL b) key)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_FUNCTION count 1)))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-2 depends on stages: Stage-1, Stage-4' ' Stage-4 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' subquery1:a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' subquery1:b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Inner Join 0 to 1' ' condition expressions:' ' 0 ' ' 1 ' ' handleSkewJoin: false' ' Select Operator' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' Group By Operator' ' aggregations:' ' expr: count(1)' ' bucketGroup: false' ' mode: hash' ' outputColumnNames: _col0' ' Reduce Output Operator' ' sort order: ' ' tag: -1' ' value expressions:' ' expr: _col0' ' type: bigint' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' Group By Operator' ' aggregations:' ' expr: count(1)' ' bucketGroup: false' ' mode: hash' ' outputColumnNames: _col0' ' Reduce Output Operator' ' sort order: ' ' tag: -1' ' value expressions:' ' expr: _col0' ' type: bigint' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: count(VALUE._col0)' ' bucketGroup: false' ' mode: mergepartial' ' outputColumnNames: _col0' ' Select Operator' ' expressions:' ' expr: _col0' ' type: bigint' ' outputColumnNames: _col0' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' '' ' Stage: Stage-4' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Inner Join 0 to 1' ' condition expressions:' ' 0 ' ' 1 ' ' handleSkewJoin: false' ' Select Operator' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-0' ' Fetch Operator' ' limit: -1' '' '' 173 rows selected >>> >>> SELECT count(1) FROM T1 a JOIN T2 b ON a.key = b.key; '_c0' '6' 1 row selected >>> >>> EXPLAIN SELECT count(1) FROM T1 a RIGHT OUTER JOIN T2 b ON a.key = b.key; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_RIGHTOUTERJOIN (TOK_TABREF (TOK_TABNAME T1) a) (TOK_TABREF (TOK_TABNAME T2) b) (= (. (TOK_TABLE_OR_COL a) key) (. (TOK_TABLE_OR_COL b) key)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_FUNCTION count 1)))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-2 depends on stages: Stage-1, Stage-4' ' Stage-4 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' subquery1:a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' subquery1:b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: (not ((key = 2) or (key = 3)))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Right Outer Join0 to 1' ' condition expressions:' ' 0 ' ' 1 ' ' handleSkewJoin: false' ' Select Operator' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' Group By Operator' ' aggregations:' ' expr: count(1)' ' bucketGroup: false' ' mode: hash' ' outputColumnNames: _col0' ' Reduce Output Operator' ' sort order: ' ' tag: -1' ' value expressions:' ' expr: _col0' ' type: bigint' ' file:!!{hive.exec.scratchdir}!! ' ' TableScan' ' Union' ' Select Operator' ' SELECT * : (no compute)' ' Group By Operator' ' aggregations:' ' expr: count(1)' ' bucketGroup: false' ' mode: hash' ' outputColumnNames: _col0' ' Reduce Output Operator' ' sort order: ' ' tag: -1' ' value expressions:' ' expr: _col0' ' type: bigint' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: count(VALUE._col0)' ' bucketGroup: false' ' mode: mergepartial' ' outputColumnNames: _col0' ' Select Operator' ' expressions:' ' expr: _col0' ' type: bigint' ' outputColumnNames: _col0' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' '' ' Stage: Stage-4' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 0' ' b ' ' TableScan' ' alias: b' ' Filter Operator' ' predicate:' ' expr: ((key = 2) or (key = 3))' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: key' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: key' ' type: int' ' tag: 1' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Right Outer Join0 to 1' ' condition expressions:' ' 0 ' ' 1 ' ' handleSkewJoin: false' ' Select Operator' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' '' ' Stage: Stage-0' ' Fetch Operator' ' limit: -1' '' '' 173 rows selected >>> >>> SELECT count(1) FROM T1 a RIGHT OUTER JOIN T2 b ON a.key = b.key; '_c0' '8' 1 row selected >>> !record