diff --git a/common/src/java/org/apache/hadoop/hive/common/jsonexplain/Vertex.java b/common/src/java/org/apache/hadoop/hive/common/jsonexplain/Vertex.java index c93059d..0451c6e 100644 --- a/common/src/java/org/apache/hadoop/hive/common/jsonexplain/Vertex.java +++ b/common/src/java/org/apache/hadoop/hive/common/jsonexplain/Vertex.java @@ -259,7 +259,7 @@ public void print(Printer printer, int indentFlag, String type, Vertex callingVe } } } - if (vertexType == VertexType.UNION) { + if (this.rootOps.isEmpty() || vertexType == VertexType.UNION) { // print dependent vertexs indentFlag++; for (int index = 0; index < this.parentConnections.size(); index++) { diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties index 5ab3076..a371fb1 100644 --- a/itests/src/test/resources/testconfiguration.properties +++ b/itests/src/test/resources/testconfiguration.properties @@ -1370,6 +1370,7 @@ spark.query.files=add_part_multiple.q, \ spark.only.query.files=spark_combine_equivalent_work.q,\ spark_dynamic_partition_pruning.q,\ spark_dynamic_partition_pruning_2.q,\ + spark_explainuser.q,\ spark_explainuser_1.q,\ spark_vectorized_dynamic_partition_pruning.q,\ spark_use_file_size_for_mapjoin.q,\ diff --git a/ql/src/test/queries/clientpositive/spark_explainuser.q b/ql/src/test/queries/clientpositive/spark_explainuser.q new file mode 100644 index 0000000..91e1d4d --- /dev/null +++ b/ql/src/test/queries/clientpositive/spark_explainuser.q @@ -0,0 +1,10 @@ +set hive.optimize.ppd=true; +set hive.ppd.remove.duplicatefilters=true; +set hive.spark.dynamic.partition.pruning=true; +set hive.optimize.metadataonly=false; +set hive.optimize.index.filter=true; +set hive.strict.checks.cartesian.product=false; +set hive.spark.explain.user=true; +set hive.spark.dynamic.partition.pruning=true; + +EXPLAIN select count(*) from srcpart where srcpart.ds in (select max(srcpart.ds) from srcpart union all select min(srcpart.ds) from srcpart); diff --git a/ql/src/test/results/clientpositive/spark/spark_explainuser.q.out b/ql/src/test/results/clientpositive/spark/spark_explainuser.q.out new file mode 100644 index 0000000..0a6fdb3 --- /dev/null +++ b/ql/src/test/results/clientpositive/spark/spark_explainuser.q.out @@ -0,0 +1,115 @@ +PREHOOK: query: EXPLAIN select count(*) from srcpart where srcpart.ds in (select max(srcpart.ds) from srcpart union all select min(srcpart.ds) from srcpart) +PREHOOK: type: QUERY +POSTHOOK: query: EXPLAIN select count(*) from srcpart where srcpart.ds in (select max(srcpart.ds) from srcpart union all select min(srcpart.ds) from srcpart) +POSTHOOK: type: QUERY +Plan optimized by CBO. + +Vertex dependency in root stage +Reducer 10 <- Map 9 (GROUP) +Reducer 11 <- Reducer 10 (GROUP), Reducer 13 (GROUP) +Reducer 13 <- Map 12 (GROUP) + +Vertex dependency in root stage +Reducer 2 <- Map 1 (PARTITION-LEVEL SORT), Reducer 6 (PARTITION-LEVEL SORT) +Reducer 3 <- Reducer 2 (GROUP) +Reducer 5 <- Map 4 (GROUP) +Reducer 6 <- Reducer 5 (GROUP), Reducer 8 (GROUP) +Reducer 8 <- Map 7 (GROUP) + +Stage-0 + Fetch Operator + limit:-1 + Stage-1 + Reducer 3 + File Output Operator [FS_34] + Group By Operator [GBY_32] (rows=1 width=8) + Output:["_col0"],aggregations:["count(VALUE._col0)"] + <-Reducer 2 [GROUP] + GROUP [RS_31] + Group By Operator [GBY_30] (rows=1 width=8) + Output:["_col0"],aggregations:["count()"] + Join Operator [JOIN_28] (rows=2200 width=10) + condition map:[{"":"{\"type\":\"Inner\",\"left\":0,\"right\":1}"}],keys:{"0":"_col0","1":"_col0"} + <-Map 1 [PARTITION-LEVEL SORT] + PARTITION-LEVEL SORT [RS_26] + PartitionCols:_col0 + Select Operator [SEL_2] (rows=2000 width=10) + Output:["_col0"] + TableScan [TS_0] (rows=2000 width=10) + default@srcpart,srcpart,Tbl:COMPLETE,Col:NONE + <-Reducer 6 [PARTITION-LEVEL SORT] + PARTITION-LEVEL SORT [RS_27] + PartitionCols:_col0 + Group By Operator [GBY_24] (rows=1 width=184) + Output:["_col0"],keys:KEY._col0 + <-Reducer 5 [GROUP] + GROUP [RS_23] + PartitionCols:_col0 + Group By Operator [GBY_22] (rows=2 width=184) + Output:["_col0"],keys:_col0 + Filter Operator [FIL_9] (rows=1 width=184) + predicate:_col0 is not null + Group By Operator [GBY_7] (rows=1 width=184) + Output:["_col0"],aggregations:["max(VALUE._col0)"] + <-Map 4 [GROUP] + GROUP [RS_6] + Group By Operator [GBY_5] (rows=1 width=184) + Output:["_col0"],aggregations:["max(ds)"] + Select Operator [SEL_4] (rows=2000 width=10) + Output:["ds"] + TableScan [TS_3] (rows=2000 width=10) + default@srcpart,srcpart,Tbl:COMPLETE,Col:NONE + <-Reducer 8 [GROUP] + GROUP [RS_23] + PartitionCols:_col0 + Group By Operator [GBY_22] (rows=2 width=184) + Output:["_col0"],keys:_col0 + Filter Operator [FIL_17] (rows=1 width=184) + predicate:_col0 is not null + Group By Operator [GBY_15] (rows=1 width=184) + Output:["_col0"],aggregations:["min(VALUE._col0)"] + <-Map 7 [GROUP] + GROUP [RS_14] + Group By Operator [GBY_13] (rows=1 width=184) + Output:["_col0"],aggregations:["min(ds)"] + Select Operator [SEL_12] (rows=2000 width=10) + Output:["ds"] + TableScan [TS_11] (rows=2000 width=10) + default@srcpart,srcpart,Tbl:COMPLETE,Col:NONE + Stage-2 + Reducer 11 + <-Reducer 10 [GROUP] + GROUP [RS_23] + PartitionCols:_col0 + Group By Operator [GBY_22] (rows=2 width=184) + Output:["_col0"],keys:_col0 + Filter Operator [FIL_9] (rows=1 width=184) + predicate:_col0 is not null + Group By Operator [GBY_7] (rows=1 width=184) + Output:["_col0"],aggregations:["max(VALUE._col0)"] + <-Map 9 [GROUP] + GROUP [RS_6] + Group By Operator [GBY_5] (rows=1 width=184) + Output:["_col0"],aggregations:["max(ds)"] + Select Operator [SEL_4] (rows=2000 width=10) + Output:["ds"] + TableScan [TS_3] (rows=2000 width=10) + default@srcpart,srcpart,Tbl:COMPLETE,Col:NONE + <-Reducer 13 [GROUP] + GROUP [RS_23] + PartitionCols:_col0 + Group By Operator [GBY_22] (rows=2 width=184) + Output:["_col0"],keys:_col0 + Filter Operator [FIL_17] (rows=1 width=184) + predicate:_col0 is not null + Group By Operator [GBY_15] (rows=1 width=184) + Output:["_col0"],aggregations:["min(VALUE._col0)"] + <-Map 12 [GROUP] + GROUP [RS_14] + Group By Operator [GBY_13] (rows=1 width=184) + Output:["_col0"],aggregations:["min(ds)"] + Select Operator [SEL_12] (rows=2000 width=10) + Output:["ds"] + TableScan [TS_11] (rows=2000 width=10) + default@srcpart,srcpart,Tbl:COMPLETE,Col:NONE +