diff --git ql/src/test/queries/clientpositive/aggr_dist1.q ql/src/test/queries/clientpositive/aggr_dist1.q new file mode 100644 index 0000000..1fd1890 --- /dev/null +++ ql/src/test/queries/clientpositive/aggr_dist1.q @@ -0,0 +1,4 @@ +EXPLAIN +SELECT count(DISTINCT x), sum(x) FROM (SELECT key AS x FROM src) z; + +SELECT count(DISTINCT x), sum(x) FROM (SELECT key AS x FROM src) z; diff --git ql/src/test/queries/clientpositive/aggr_dist1_map.q ql/src/test/queries/clientpositive/aggr_dist1_map.q new file mode 100644 index 0000000..530e8ef --- /dev/null +++ ql/src/test/queries/clientpositive/aggr_dist1_map.q @@ -0,0 +1,6 @@ +set hive.map.aggr=true; + +EXPLAIN +SELECT count(DISTINCT x), sum(x) FROM (SELECT key AS x FROM src) z; + +SELECT count(DISTINCT x), sum(x) FROM (SELECT key AS x FROM src) z; diff --git ql/src/test/results/clientpositive/aggr_dist1.q.out ql/src/test/results/clientpositive/aggr_dist1.q.out new file mode 100644 index 0000000..de4cb9c --- /dev/null +++ ql/src/test/results/clientpositive/aggr_dist1.q.out @@ -0,0 +1,79 @@ +ABSTRACT SYNTAX TREE: + (TOK_QUERY (TOK_FROM (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF src)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_COLREF key) x)))) z)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_FUNCTIONDI count (TOK_COLREF x))) (TOK_SELEXPR (TOK_FUNCTION sum (TOK_COLREF x)))))) + +STAGE DEPENDENCIES: + Stage-1 is a root stage + Stage-2 depends on stages: Stage-1 + Stage-0 is a root stage + +STAGE PLANS: + Stage: Stage-1 + Map Reduce + Alias -> Map Operator Tree: + z:src + Select Operator + expressions: + expr: key + type: string + Select Operator + expressions: + expr: 0 + type: string + Reduce Output Operator + key expressions: + expr: 0 + type: string + sort order: + + Map-reduce partition columns: + expr: 0 + type: string + tag: -1 + Reduce Operator Tree: + Group By Operator + aggregations: + expr: sum(UDFToDouble(KEY.0)) + expr: count(DISTINCT KEY.0) + mode: partial1 + File Output Operator + compressed: false + table: + input format: org.apache.hadoop.mapred.SequenceFileInputFormat + output format: org.apache.hadoop.mapred.SequenceFileOutputFormat + name: binary_table + + Stage: Stage-2 + Map Reduce + Alias -> Map Operator Tree: + /vm/tmp/hive/build/ql/tmp/634288584/67253057.10002 + Reduce Output Operator + sort order: + tag: -1 + value expressions: + expr: 0 + type: double + expr: 1 + type: bigint + Reduce Operator Tree: + Group By Operator + aggregations: + expr: sum(VALUE.0) + expr: count(VALUE.1) + mode: final + Select Operator + expressions: + expr: 1 + type: bigint + expr: 0 + type: double + File Output Operator + compressed: false + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat + + Stage: Stage-0 + Fetch Operator + limit: -1 + + +309 130091.0 diff --git ql/src/test/results/clientpositive/aggr_dist1_map.q.out ql/src/test/results/clientpositive/aggr_dist1_map.q.out new file mode 100644 index 0000000..9ed16d3 --- /dev/null +++ ql/src/test/results/clientpositive/aggr_dist1_map.q.out @@ -0,0 +1,92 @@ +ABSTRACT SYNTAX TREE: + (TOK_QUERY (TOK_FROM (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF src)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_COLREF key) x)))) z)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_FUNCTIONDI count (TOK_COLREF x))) (TOK_SELEXPR (TOK_FUNCTION sum (TOK_COLREF x)))))) + +STAGE DEPENDENCIES: + Stage-1 is a root stage + Stage-2 depends on stages: Stage-1 + Stage-0 is a root stage + +STAGE PLANS: + Stage: Stage-1 + Map Reduce + Alias -> Map Operator Tree: + z:src + Select Operator + expressions: + expr: key + type: string + Select Operator + expressions: + expr: 0 + type: string + Group By Operator + aggregations: + expr: sum(UDFToDouble(0)) + expr: count(DISTINCT 0) + keys: + expr: 0 + type: string + mode: hash + Reduce Output Operator + key expressions: + expr: 0 + type: string + sort order: + + Map-reduce partition columns: + expr: 0 + type: string + tag: -1 + value expressions: + expr: 1 + type: double + expr: 2 + type: bigint + Reduce Operator Tree: + Group By Operator + aggregations: + expr: count(DISTINCT KEY.0) + expr: sum(VALUE.0) + mode: partial2 + File Output Operator + compressed: false + table: + input format: org.apache.hadoop.mapred.SequenceFileInputFormat + output format: org.apache.hadoop.mapred.SequenceFileOutputFormat + name: binary_table + + Stage: Stage-2 + Map Reduce + Alias -> Map Operator Tree: + /vm/tmp/hive/build/ql/tmp/85061085/23785251.10002 + Reduce Output Operator + sort order: + tag: -1 + value expressions: + expr: 0 + type: double + expr: 1 + type: bigint + Reduce Operator Tree: + Group By Operator + aggregations: + expr: sum(VALUE.0) + expr: count(VALUE.1) + mode: final + Select Operator + expressions: + expr: 1 + type: bigint + expr: 0 + type: double + File Output Operator + compressed: false + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat + + Stage: Stage-0 + Fetch Operator + limit: -1 + + +309 130091.0