PREHOOK: query: -- Set merging to false above to make the explain more readable CREATE TABLE T1(a STRING, b STRING, c STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ' STORED AS TEXTFILE PREHOOK: type: CREATETABLE POSTHOOK: query: -- Set merging to false above to make the explain more readable CREATE TABLE T1(a STRING, b STRING, c STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ' STORED AS TEXTFILE POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@T1 PREHOOK: query: LOAD DATA LOCAL INPATH '../data/files/grouping_sets.txt' INTO TABLE T1 PREHOOK: type: LOAD PREHOOK: Output: default@t1 POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/grouping_sets.txt' INTO TABLE T1 POSTHOOK: type: LOAD POSTHOOK: Output: default@t1 PREHOOK: query: -- This tests that cubes and rollups work fine inside sub-queries. EXPLAIN SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b PREHOOK: type: QUERY POSTHOOK: query: -- This tests that cubes and rollups work fine inside sub-queries. EXPLAIN SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b POSTHOOK: type: QUERY ABSTRACT SYNTAX TREE: (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME T1))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL a)) (TOK_SELEXPR (TOK_TABLE_OR_COL b)) (TOK_SELEXPR (TOK_FUNCTIONSTAR count))) (TOK_WHERE (< (TOK_TABLE_OR_COL a) 3)) (TOK_CUBE_GROUPBY (TOK_TABLE_OR_COL a) (TOK_TABLE_OR_COL b)))) subq1) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME T1))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL a)) (TOK_SELEXPR (TOK_TABLE_OR_COL b)) (TOK_SELEXPR (TOK_FUNCTIONSTAR count))) (TOK_WHERE (< (TOK_TABLE_OR_COL a) 3)) (TOK_CUBE_GROUPBY (TOK_TABLE_OR_COL a) (TOK_TABLE_OR_COL b)))) subq2) (= (. (TOK_TABLE_OR_COL subq1) a) (. (TOK_TABLE_OR_COL subq2) a)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_ORDERBY (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq1) a)) (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq1) b)) (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq2) a)) (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq2) b))))) STAGE DEPENDENCIES: Stage-1 is a root stage Stage-2 depends on stages: Stage-1, Stage-4 Stage-3 depends on stages: Stage-2 Stage-4 is a root stage Stage-0 is a root stage STAGE PLANS: Stage: Stage-1 Map Reduce Alias -> Map Operator Tree: subq1:t1 TableScan alias: t1 Filter Operator predicate: expr: (a < 3) type: boolean Select Operator expressions: expr: a type: string expr: b type: string outputColumnNames: a, b Group By Operator aggregations: expr: count() bucketGroup: false keys: expr: a type: string expr: b type: string expr: '0' type: string mode: hash outputColumnNames: _col0, _col1, _col2, _col3 Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string sort order: +++ Map-reduce partition columns: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string tag: -1 value expressions: expr: _col3 type: bigint Reduce Operator Tree: Group By Operator aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string expr: KEY._col1 type: string expr: KEY._col2 type: string mode: mergepartial outputColumnNames: _col0, _col1, _col2, _col3 Select Operator expressions: expr: _col0 type: string expr: _col1 type: string expr: _col3 type: bigint outputColumnNames: _col0, _col1, _col2 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: $INTNAME Reduce Output Operator key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: 0 value expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint $INTNAME1 Reduce Output Operator key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: 1 value expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint Reduce Operator Tree: Join Operator condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col0} {VALUE._col1} {VALUE._col2} 1 {VALUE._col0} {VALUE._col1} {VALUE._col2} handleSkewJoin: false outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5 Select Operator expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint expr: _col3 type: string expr: _col4 type: string expr: _col5 type: bigint outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5 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-3 Map Reduce Alias -> Map Operator Tree: #### A masked pattern was here #### Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string expr: _col3 type: string expr: _col4 type: string sort order: ++++ tag: -1 value expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint expr: _col3 type: string expr: _col4 type: string expr: _col5 type: bigint Reduce Operator Tree: Extract 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: subq2:t1 TableScan alias: t1 Filter Operator predicate: expr: (a < 3) type: boolean Select Operator expressions: expr: a type: string expr: b type: string outputColumnNames: a, b Group By Operator aggregations: expr: count() bucketGroup: false keys: expr: a type: string expr: b type: string expr: '0' type: string mode: hash outputColumnNames: _col0, _col1, _col2, _col3 Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string sort order: +++ Map-reduce partition columns: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string tag: -1 value expressions: expr: _col3 type: bigint Reduce Operator Tree: Group By Operator aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string expr: KEY._col1 type: string expr: KEY._col2 type: string mode: mergepartial outputColumnNames: _col0, _col1, _col2, _col3 Select Operator expressions: expr: _col0 type: string expr: _col1 type: string expr: _col3 type: bigint outputColumnNames: _col0, _col1, _col2 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 PREHOOK: query: SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b PREHOOK: type: QUERY PREHOOK: Input: default@t1 #### A masked pattern was here #### POSTHOOK: query: SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b POSTHOOK: type: QUERY POSTHOOK: Input: default@t1 #### A masked pattern was here #### 1 NULL 1 1 NULL 1 1 NULL 1 1 1 1 1 1 1 1 NULL 1 1 1 1 1 1 1 2 NULL 2 2 NULL 2 2 NULL 2 2 2 1 2 NULL 2 2 3 1 2 2 1 2 NULL 2 2 2 1 2 2 1 2 2 1 2 3 1 2 3 1 2 NULL 2 2 3 1 2 2 1 2 3 1 2 3 1 PREHOOK: query: -- Since 4 grouping sets would be generated for each sub-query, an additional MR job should be created -- for each of them EXPLAIN SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b PREHOOK: type: QUERY POSTHOOK: query: -- Since 4 grouping sets would be generated for each sub-query, an additional MR job should be created -- for each of them EXPLAIN SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b POSTHOOK: type: QUERY ABSTRACT SYNTAX TREE: (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME T1))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL a)) (TOK_SELEXPR (TOK_TABLE_OR_COL b)) (TOK_SELEXPR (TOK_FUNCTIONSTAR count))) (TOK_WHERE (< (TOK_TABLE_OR_COL a) 3)) (TOK_CUBE_GROUPBY (TOK_TABLE_OR_COL a) (TOK_TABLE_OR_COL b)))) subq1) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME T1))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL a)) (TOK_SELEXPR (TOK_TABLE_OR_COL b)) (TOK_SELEXPR (TOK_FUNCTIONSTAR count))) (TOK_WHERE (< (TOK_TABLE_OR_COL a) 3)) (TOK_CUBE_GROUPBY (TOK_TABLE_OR_COL a) (TOK_TABLE_OR_COL b)))) subq2) (= (. (TOK_TABLE_OR_COL subq1) a) (. (TOK_TABLE_OR_COL subq2) a)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_ORDERBY (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq1) a)) (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq1) b)) (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq2) a)) (TOK_TABSORTCOLNAMEASC (. (TOK_TABLE_OR_COL subq2) b))))) STAGE DEPENDENCIES: Stage-1 is a root stage Stage-2 depends on stages: Stage-1 Stage-3 depends on stages: Stage-2, Stage-6 Stage-4 depends on stages: Stage-3 Stage-5 is a root stage Stage-6 depends on stages: Stage-5 Stage-0 is a root stage STAGE PLANS: Stage: Stage-1 Map Reduce Alias -> Map Operator Tree: subq1:t1 TableScan alias: t1 Filter Operator predicate: expr: (a < 3) type: boolean Select Operator expressions: expr: a type: string expr: b type: string outputColumnNames: a, b Group By Operator aggregations: expr: count() bucketGroup: false keys: expr: a type: string expr: b type: string mode: hash outputColumnNames: _col0, _col1, _col2 Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string sort order: ++ Map-reduce partition columns: expr: _col0 type: string expr: _col1 type: string tag: -1 value expressions: expr: _col2 type: bigint Reduce Operator Tree: Group By Operator aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string expr: KEY._col1 type: string expr: '0' type: string mode: partials 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: #### A masked pattern was here #### Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string sort order: +++ Map-reduce partition columns: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string tag: -1 value expressions: expr: _col3 type: bigint Reduce Operator Tree: Group By Operator aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string expr: KEY._col1 type: string expr: KEY._col2 type: string mode: final outputColumnNames: _col0, _col1, _col2, _col3 Select Operator expressions: expr: _col0 type: string expr: _col1 type: string expr: _col3 type: bigint outputColumnNames: _col0, _col1, _col2 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-3 Map Reduce Alias -> Map Operator Tree: $INTNAME Reduce Output Operator key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: 0 value expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint $INTNAME1 Reduce Output Operator key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: 1 value expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint Reduce Operator Tree: Join Operator condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col0} {VALUE._col1} {VALUE._col2} 1 {VALUE._col0} {VALUE._col1} {VALUE._col2} handleSkewJoin: false outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5 Select Operator expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint expr: _col3 type: string expr: _col4 type: string expr: _col5 type: bigint outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5 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-4 Map Reduce Alias -> Map Operator Tree: #### A masked pattern was here #### Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string expr: _col3 type: string expr: _col4 type: string sort order: ++++ tag: -1 value expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: bigint expr: _col3 type: string expr: _col4 type: string expr: _col5 type: bigint Reduce Operator Tree: Extract 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-5 Map Reduce Alias -> Map Operator Tree: subq2:t1 TableScan alias: t1 Filter Operator predicate: expr: (a < 3) type: boolean Select Operator expressions: expr: a type: string expr: b type: string outputColumnNames: a, b Group By Operator aggregations: expr: count() bucketGroup: false keys: expr: a type: string expr: b type: string mode: hash outputColumnNames: _col0, _col1, _col2 Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string sort order: ++ Map-reduce partition columns: expr: _col0 type: string expr: _col1 type: string tag: -1 value expressions: expr: _col2 type: bigint Reduce Operator Tree: Group By Operator aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string expr: KEY._col1 type: string expr: '0' type: string mode: partials 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-6 Map Reduce Alias -> Map Operator Tree: #### A masked pattern was here #### Reduce Output Operator key expressions: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string sort order: +++ Map-reduce partition columns: expr: _col0 type: string expr: _col1 type: string expr: _col2 type: string tag: -1 value expressions: expr: _col3 type: bigint Reduce Operator Tree: Group By Operator aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string expr: KEY._col1 type: string expr: KEY._col2 type: string mode: final outputColumnNames: _col0, _col1, _col2, _col3 Select Operator expressions: expr: _col0 type: string expr: _col1 type: string expr: _col3 type: bigint outputColumnNames: _col0, _col1, _col2 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 PREHOOK: query: SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b PREHOOK: type: QUERY PREHOOK: Input: default@t1 #### A masked pattern was here #### POSTHOOK: query: SELECT * FROM (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq1 join (SELECT a, b, count(*) from T1 where a < 3 group by a, b with cube) subq2 on subq1.a = subq2.a order by subq1.a, subq1.b, subq2.a, subq2.b POSTHOOK: type: QUERY POSTHOOK: Input: default@t1 #### A masked pattern was here #### 1 NULL 1 1 NULL 1 1 NULL 1 1 1 1 1 1 1 1 NULL 1 1 1 1 1 1 1 2 NULL 2 2 NULL 2 2 NULL 2 2 2 1 2 NULL 2 2 3 1 2 2 1 2 NULL 2 2 2 1 2 2 1 2 2 1 2 3 1 2 3 1 2 NULL 2 2 3 1 2 2 1 2 3 1 2 3 1