PREHOOK: query: -- This test is used for testing EXPLAIN LOGICAL command -- Create some views CREATE VIEW V1 AS SELECT key, value from src PREHOOK: type: CREATEVIEW POSTHOOK: query: -- This test is used for testing EXPLAIN LOGICAL command -- Create some views CREATE VIEW V1 AS SELECT key, value from src POSTHOOK: type: CREATEVIEW POSTHOOK: Output: default@V1 PREHOOK: query: CREATE VIEW V2 AS SELECT ds, key, value FROM srcpart WHERE ds IS NOT NULL PREHOOK: type: CREATEVIEW POSTHOOK: query: CREATE VIEW V2 AS SELECT ds, key, value FROM srcpart WHERE ds IS NOT NULL POSTHOOK: type: CREATEVIEW POSTHOOK: Output: default@V2 PREHOOK: query: CREATE VIEW V3 AS SELECT src1.key, src2.value FROM V2 src1 JOIN src src2 ON src1.key = src2.key WHERE src1.ds IS NOT NULL PREHOOK: type: CREATEVIEW PREHOOK: Input: default@v2 POSTHOOK: query: CREATE VIEW V3 AS SELECT src1.key, src2.value FROM V2 src1 JOIN src src2 ON src1.key = src2.key WHERE src1.ds IS NOT NULL POSTHOOK: type: CREATEVIEW POSTHOOK: Input: default@v2 POSTHOOK: Output: default@V3 PREHOOK: query: CREATE VIEW V4 AS SELECT src1.key, src2.value as value1, src3.value as value2 FROM V1 src1 JOIN V2 src2 on src1.key = src2.key JOIN src src3 ON src2.key = src3.key PREHOOK: type: CREATEVIEW PREHOOK: Input: default@v1 PREHOOK: Input: default@v2 POSTHOOK: query: CREATE VIEW V4 AS SELECT src1.key, src2.value as value1, src3.value as value2 FROM V1 src1 JOIN V2 src2 on src1.key = src2.key JOIN src src3 ON src2.key = src3.key POSTHOOK: type: CREATEVIEW POSTHOOK: Input: default@v1 POSTHOOK: Input: default@v2 POSTHOOK: Output: default@V4 PREHOOK: query: -- Simple select queries, union queries and join queries EXPLAIN LOGICAL SELECT key, count(1) FROM srcpart WHERE ds IS NOT NULL GROUP BY key PREHOOK: type: QUERY POSTHOOK: query: -- Simple select queries, union queries and join queries EXPLAIN LOGICAL SELECT key, count(1) FROM srcpart WHERE ds IS NOT NULL GROUP BY key POSTHOOK: type: QUERY LOGICAL PLAN srcpart TableScan (TS_0) alias: srcpart Select Operator (SEL_2) expressions: expr: key type: string outputColumnNames: key Group By Operator (GBY_3) aggregations: expr: count(1) bucketGroup: false keys: expr: key type: string mode: hash outputColumnNames: _col0, _col1 Reduce Output Operator (RS_4) key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: -1 value expressions: expr: _col1 type: bigint Group By Operator (GBY_5) aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string mode: mergepartial outputColumnNames: _col0, _col1 Select Operator (SEL_6) expressions: expr: _col0 type: string expr: _col1 type: bigint outputColumnNames: _col0, _col1 File Output Operator (FS_7) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat PREHOOK: query: EXPLAIN LOGICAL SELECT key, count(1) FROM (SELECT key, value FROM src) subq1 GROUP BY key PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT key, count(1) FROM (SELECT key, value FROM src) subq1 GROUP BY key POSTHOOK: type: QUERY LOGICAL PLAN subq1:src TableScan (TS_0) alias: src Select Operator (SEL_1) expressions: expr: key type: string outputColumnNames: _col0 Group By Operator (GBY_3) aggregations: expr: count(1) bucketGroup: false keys: expr: _col0 type: string mode: hash outputColumnNames: _col0, _col1 Reduce Output Operator (RS_4) key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: -1 value expressions: expr: _col1 type: bigint Group By Operator (GBY_5) aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string mode: mergepartial outputColumnNames: _col0, _col1 Select Operator (SEL_6) expressions: expr: _col0 type: string expr: _col1 type: bigint outputColumnNames: _col0, _col1 File Output Operator (FS_7) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat PREHOOK: query: EXPLAIN LOGICAL SELECT * FROM ( SELECT key, value FROM src UNION ALL SELECT key, value FROM srcpart WHERE ds IS NOT NULL ) S1 PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT * FROM ( SELECT key, value FROM src UNION ALL SELECT key, value FROM srcpart WHERE ds IS NOT NULL ) S1 POSTHOOK: type: QUERY LOGICAL PLAN null-subquery1:s1-subquery1:src TableScan (TS_0) alias: src Select Operator (SEL_1) expressions: expr: key type: string expr: value type: string outputColumnNames: _col0, _col1 Union (UNION_5) Select Operator (SEL_6) expressions: expr: _col0 type: string expr: _col1 type: string outputColumnNames: _col0, _col1 File Output Operator (FS_7) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat null-subquery2:s1-subquery2:srcpart TableScan (TS_2) alias: srcpart Select Operator (SEL_4) expressions: expr: key type: string expr: value type: string outputColumnNames: _col0, _col1 Union (UNION_5) PREHOOK: query: EXPLAIN LOGICAL SELECT S1.key, S2.value FROM src S1 JOIN srcpart S2 ON S1.key = S2.key WHERE ds IS NOT NULL PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT S1.key, S2.value FROM src S1 JOIN srcpart S2 ON S1.key = S2.key WHERE ds IS NOT NULL POSTHOOK: type: QUERY LOGICAL PLAN s1 TableScan (TS_1) alias: s1 Reduce Output Operator (RS_2) key expressions: expr: key type: string sort order: + Map-reduce partition columns: expr: key type: string tag: 0 value expressions: expr: key type: string Join Operator (JOIN_4) condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col0} 1 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col5 Select Operator (SEL_6) expressions: expr: _col0 type: string expr: _col5 type: string outputColumnNames: _col0, _col1 File Output Operator (FS_7) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat s2 TableScan (TS_0) alias: s2 Reduce Output Operator (RS_3) key expressions: expr: key type: string sort order: + Map-reduce partition columns: expr: key type: string tag: 1 value expressions: expr: value type: string Join Operator (JOIN_4) condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col0} 1 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col5 PREHOOK: query: -- With views EXPLAIN LOGICAL SELECT * FROM V1 PREHOOK: type: QUERY POSTHOOK: query: -- With views EXPLAIN LOGICAL SELECT * FROM V1 POSTHOOK: type: QUERY LOGICAL PLAN v1:src TableScan (TS_0) alias: src Select Operator (SEL_1) expressions: expr: key type: string expr: value type: string outputColumnNames: _col0, _col1 File Output Operator (FS_3) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat PREHOOK: query: EXPLAIN LOGICAL SELECT * FROM V2 PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT * FROM V2 POSTHOOK: type: QUERY LOGICAL PLAN v2:srcpart TableScan (TS_0) alias: srcpart Select Operator (SEL_2) expressions: expr: ds type: string expr: key type: string expr: value type: string outputColumnNames: _col0, _col1, _col2 File Output Operator (FS_4) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat PREHOOK: query: EXPLAIN LOGICAL SELECT * FROM V3 PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT * FROM V3 POSTHOOK: type: QUERY LOGICAL PLAN v3:src1:srcpart TableScan (TS_0) alias: srcpart Select Operator (SEL_2) expressions: expr: key type: string outputColumnNames: _col1 Reduce Output Operator (RS_4) key expressions: expr: _col1 type: string sort order: + Map-reduce partition columns: expr: _col1 type: string tag: 0 value expressions: expr: _col1 type: string Join Operator (JOIN_6) condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col1} 1 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col1, _col4 Select Operator (SEL_8) expressions: expr: _col1 type: string expr: _col4 type: string outputColumnNames: _col0, _col1 File Output Operator (FS_10) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat v3:src2 TableScan (TS_3) alias: src2 Reduce Output Operator (RS_5) key expressions: expr: key type: string sort order: + Map-reduce partition columns: expr: key type: string tag: 1 value expressions: expr: value type: string Join Operator (JOIN_6) condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col1} 1 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col1, _col4 PREHOOK: query: EXPLAIN LOGICAL SELECT * FROM V4 PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT * FROM V4 POSTHOOK: type: QUERY LOGICAL PLAN v4:src1:src TableScan (TS_3) alias: src Select Operator (SEL_4) expressions: expr: key type: string outputColumnNames: _col0 Reduce Output Operator (RS_6) key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: 0 value expressions: expr: _col0 type: string Join Operator (JOIN_9) condition map: Inner Join 0 to 1 Inner Join 1 to 2 condition expressions: 0 {VALUE._col0} 1 {VALUE._col2} 2 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col4, _col6 Select Operator (SEL_10) expressions: expr: _col0 type: string expr: _col4 type: string expr: _col6 type: string outputColumnNames: _col0, _col1, _col2 File Output Operator (FS_12) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat v4:src2:srcpart TableScan (TS_0) alias: srcpart Select Operator (SEL_2) expressions: expr: key type: string expr: value type: string outputColumnNames: _col1, _col2 Reduce Output Operator (RS_7) key expressions: expr: _col1 type: string sort order: + Map-reduce partition columns: expr: _col1 type: string tag: 1 value expressions: expr: _col2 type: string Join Operator (JOIN_9) condition map: Inner Join 0 to 1 Inner Join 1 to 2 condition expressions: 0 {VALUE._col0} 1 {VALUE._col2} 2 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col4, _col6 v4:src3 TableScan (TS_5) alias: src3 Reduce Output Operator (RS_8) key expressions: expr: key type: string sort order: + Map-reduce partition columns: expr: key type: string tag: 2 value expressions: expr: value type: string Join Operator (JOIN_9) condition map: Inner Join 0 to 1 Inner Join 1 to 2 condition expressions: 0 {VALUE._col0} 1 {VALUE._col2} 2 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col4, _col6 PREHOOK: query: -- The table should show up in the explain logical even if none -- of the partitions are selected. CREATE VIEW V5 as SELECT * FROM srcpart where ds = '10' PREHOOK: type: CREATEVIEW POSTHOOK: query: -- The table should show up in the explain logical even if none -- of the partitions are selected. CREATE VIEW V5 as SELECT * FROM srcpart where ds = '10' POSTHOOK: type: CREATEVIEW POSTHOOK: Output: default@V5 PREHOOK: query: EXPLAIN LOGICAL SELECT * FROM V5 PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT * FROM V5 POSTHOOK: type: QUERY LOGICAL PLAN v5:srcpart TableScan (TS_0) alias: srcpart Filter Operator (FIL_5) predicate: expr: (ds = '10') type: boolean Select Operator (SEL_2) expressions: expr: key type: string expr: value type: string expr: ds type: string expr: hr type: string outputColumnNames: _col0, _col1, _col2, _col3 File Output Operator (FS_4) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat PREHOOK: query: EXPLAIN LOGICAL SELECT s1.key, s1.cnt, s2.value FROM (SELECT key, count(value) as cnt FROM src GROUP BY key) s1 JOIN src s2 ON (s1.key = s2.key) ORDER BY s1.key PREHOOK: type: QUERY POSTHOOK: query: EXPLAIN LOGICAL SELECT s1.key, s1.cnt, s2.value FROM (SELECT key, count(value) as cnt FROM src GROUP BY key) s1 JOIN src s2 ON (s1.key = s2.key) ORDER BY s1.key POSTHOOK: type: QUERY LOGICAL PLAN s1:src TableScan (TS_0) alias: src Select Operator (SEL_1) expressions: expr: key type: string expr: value type: string outputColumnNames: key, value Group By Operator (GBY_2) aggregations: expr: count(value) bucketGroup: false keys: expr: key type: string mode: hash outputColumnNames: _col0, _col1 Reduce Output Operator (RS_3) key expressions: expr: _col0 type: string sort order: + Map-reduce partition columns: expr: _col0 type: string tag: -1 value expressions: expr: _col1 type: bigint Group By Operator (GBY_4) aggregations: expr: count(VALUE._col0) bucketGroup: false keys: expr: KEY._col0 type: string mode: mergepartial outputColumnNames: _col0, _col1 Select Operator (SEL_5) expressions: expr: _col0 type: string expr: _col1 type: bigint outputColumnNames: _col0, _col1 Reduce Output Operator (RS_7) 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: bigint Join Operator (JOIN_9) condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col0} {VALUE._col1} 1 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col1, _col3 Select Operator (SEL_10) expressions: expr: _col0 type: string expr: _col1 type: bigint expr: _col3 type: string outputColumnNames: _col0, _col1, _col2 Reduce Output Operator (RS_11) key expressions: expr: _col0 type: string sort order: + tag: -1 value expressions: expr: _col0 type: string expr: _col1 type: bigint expr: _col2 type: string Extract (EX_12) File Output Operator (FS_13) compressed: false GlobalTableId: 0 table: input format: org.apache.hadoop.mapred.TextInputFormat output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat s2 TableScan (TS_6) alias: s2 Reduce Output Operator (RS_8) key expressions: expr: key type: string sort order: + Map-reduce partition columns: expr: key type: string tag: 1 value expressions: expr: value type: string Join Operator (JOIN_9) condition map: Inner Join 0 to 1 condition expressions: 0 {VALUE._col0} {VALUE._col1} 1 {VALUE._col1} handleSkewJoin: false outputColumnNames: _col0, _col1, _col3