You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2016/12/20 20:08:11 UTC
hive git commit: HIVE-15409: Add support for GROUPING function with
grouping sets (Jesus Camacho Rodriguez,
reviewed by Ashutosh Chauhan) (addendum)
Repository: hive
Updated Branches:
refs/heads/master 9cc03722d -> fc3005236
HIVE-15409: Add support for GROUPING function with grouping sets (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan) (addendum)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/fc300523
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/fc300523
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/fc300523
Branch: refs/heads/master
Commit: fc3005236b899bb428df4dcd9832babcd6fff875
Parents: 9cc0372
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Tue Dec 20 20:07:54 2016 +0000
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Tue Dec 20 20:07:54 2016 +0000
----------------------------------------------------------------------
.../hadoop/hive/ql/parse/SemanticAnalyzer.java | 2 +-
.../groupby_grouping_sets_grouping.q.out | 90 ++++++++++----------
2 files changed, 47 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/fc300523/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 5ff74f2..71d34eb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -3046,7 +3046,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
ParseDriver.adaptor.addChild(child1, ParseDriver.adaptor.create(
HiveParser.Identifier, VirtualColumn.GROUPINGID.getName()));
ASTNode child2 = (ASTNode) ParseDriver.adaptor.create(HiveParser.IntegralLiteral,
- String.valueOf(IntMath.mod(-i, grpByAstExprs.size())));
+ String.valueOf(IntMath.mod(-i-1, grpByAstExprs.size())));
root.setChild(1, child1);
root.addChild(child2);
found.setValue(true);
http://git-wip-us.apache.org/repos/asf/hive/blob/fc300523/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out b/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
index dcc80f7..62f40cd 100644
--- a/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
+++ b/ql/src/test/results/clientpositive/groupby_grouping_sets_grouping.q.out
@@ -56,7 +56,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 4 Data size: 40 Basic stats: COMPLETE Column stats: NONE
Select Operator
- expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 0) (type: tinyint), grouping(_col2, 1) (type: tinyint)
+ expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 1) (type: tinyint), grouping(_col2, 0) (type: tinyint)
outputColumnNames: _col0, _col1, _col2, _col3, _col4
Statistics: Num rows: 4 Data size: 40 Basic stats: COMPLETE Column stats: NONE
File Output Operator
@@ -86,15 +86,15 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@t1
#### A masked pattern was here ####
NULL NULL 0 0 0
-1 NULL 1 1 0
+1 NULL 1 0 1
1 NULL 3 1 1
1 1 3 1 1
-2 NULL 1 1 0
+2 NULL 1 0 1
2 2 3 1 1
-3 NULL 1 1 0
+3 NULL 1 0 1
3 NULL 3 1 1
3 3 3 1 1
-4 NULL 1 1 0
+4 NULL 1 0 1
4 5 3 1 1
PREHOOK: query: explain
select key, value, `grouping__id`, grouping(key), grouping(value)
@@ -138,7 +138,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Select Operator
- expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 0) (type: tinyint), grouping(_col2, 1) (type: tinyint)
+ expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 1) (type: tinyint), grouping(_col2, 0) (type: tinyint)
outputColumnNames: _col0, _col1, _col2, _col3, _col4
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
File Output Operator
@@ -168,20 +168,20 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@t1
#### A masked pattern was here ####
NULL NULL 0 0 0
-NULL NULL 2 0 1
-NULL 1 2 0 1
-NULL 2 2 0 1
-NULL 3 2 0 1
-NULL 5 2 0 1
-1 NULL 1 1 0
+NULL NULL 2 1 0
+NULL 1 2 1 0
+NULL 2 2 1 0
+NULL 3 2 1 0
+NULL 5 2 1 0
+1 NULL 1 0 1
1 NULL 3 1 1
1 1 3 1 1
-2 NULL 1 1 0
+2 NULL 1 0 1
2 2 3 1 1
-3 NULL 1 1 0
+3 NULL 1 0 1
3 NULL 3 1 1
3 3 3 1 1
-4 NULL 1 1 0
+4 NULL 1 0 1
4 5 3 1 1
PREHOOK: query: explain
select key, value
@@ -227,7 +227,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: (UDFToInteger(grouping(_col2, 0)) = 1) (type: boolean)
+ predicate: (UDFToInteger(grouping(_col2, 1)) = 1) (type: boolean)
Statistics: Num rows: 3 Data size: 30 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: _col0 (type: int), _col1 (type: int)
@@ -261,15 +261,16 @@ having grouping(key) = 1
POSTHOOK: type: QUERY
POSTHOOK: Input: default@t1
#### A masked pattern was here ####
-1 NULL
+NULL NULL
+NULL 1
+NULL 2
+NULL 3
+NULL 5
1 NULL
1 1
-2 NULL
2 2
3 NULL
-3 NULL
3 3
-4 NULL
4 5
PREHOOK: query: explain
select key, value, grouping(key)+grouping(value) as x
@@ -318,10 +319,10 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((UDFToInteger(grouping(_col2, 0)) = 1) or (UDFToInteger(grouping(_col2, 1)) = 1)) (type: boolean)
+ predicate: ((UDFToInteger(grouping(_col2, 1)) = 1) or (UDFToInteger(grouping(_col2, 0)) = 1)) (type: boolean)
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Select Operator
- expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 0) + grouping(_col2, 1)) (type: tinyint)
+ expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 1) + grouping(_col2, 0)) (type: tinyint)
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
File Output Operator
@@ -432,7 +433,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 4 Data size: 40 Basic stats: COMPLETE Column stats: NONE
Select Operator
- expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 0) (type: tinyint), grouping(_col2, 1) (type: tinyint)
+ expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 1) (type: tinyint), grouping(_col2, 0) (type: tinyint)
outputColumnNames: _col0, _col1, _col2, _col3, _col4
Statistics: Num rows: 4 Data size: 40 Basic stats: COMPLETE Column stats: NONE
File Output Operator
@@ -462,15 +463,15 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@t1
#### A masked pattern was here ####
NULL NULL 0 0 0
-1 NULL 1 1 0
+1 NULL 1 0 1
1 NULL 3 1 1
1 1 3 1 1
-2 NULL 1 1 0
+2 NULL 1 0 1
2 2 3 1 1
-3 NULL 1 1 0
+3 NULL 1 0 1
3 NULL 3 1 1
3 3 3 1 1
-4 NULL 1 1 0
+4 NULL 1 0 1
4 5 3 1 1
PREHOOK: query: explain
select key, value, `grouping__id`, grouping(key), grouping(value)
@@ -514,7 +515,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Select Operator
- expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 0) (type: tinyint), grouping(_col2, 1) (type: tinyint)
+ expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int), grouping(_col2, 1) (type: tinyint), grouping(_col2, 0) (type: tinyint)
outputColumnNames: _col0, _col1, _col2, _col3, _col4
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
File Output Operator
@@ -544,20 +545,20 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@t1
#### A masked pattern was here ####
NULL NULL 0 0 0
-NULL NULL 2 0 1
-NULL 1 2 0 1
-NULL 2 2 0 1
-NULL 3 2 0 1
-NULL 5 2 0 1
-1 NULL 1 1 0
+NULL NULL 2 1 0
+NULL 1 2 1 0
+NULL 2 2 1 0
+NULL 3 2 1 0
+NULL 5 2 1 0
+1 NULL 1 0 1
1 NULL 3 1 1
1 1 3 1 1
-2 NULL 1 1 0
+2 NULL 1 0 1
2 2 3 1 1
-3 NULL 1 1 0
+3 NULL 1 0 1
3 NULL 3 1 1
3 3 3 1 1
-4 NULL 1 1 0
+4 NULL 1 0 1
4 5 3 1 1
PREHOOK: query: explain
select key, value
@@ -592,7 +593,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 12 Data size: 120 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: (grouping(_col2, 0) = 1) (type: boolean)
+ predicate: (grouping(_col2, 1) = 1) (type: boolean)
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Reduce Output Operator
key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int)
@@ -634,15 +635,16 @@ having grouping(key) = 1
POSTHOOK: type: QUERY
POSTHOOK: Input: default@t1
#### A masked pattern was here ####
-1 NULL
+NULL NULL
+NULL 1
+NULL 2
+NULL 3
+NULL 5
1 NULL
1 1
-2 NULL
2 2
3 NULL
-3 NULL
3 3
-4 NULL
4 5
PREHOOK: query: explain
select key, value, grouping(key)+grouping(value) as x
@@ -680,7 +682,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 12 Data size: 120 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((grouping(_col2, 0) = 1) or (grouping(_col2, 1) = 1)) (type: boolean)
+ predicate: ((grouping(_col2, 1) = 1) or (grouping(_col2, 0) = 1)) (type: boolean)
Statistics: Num rows: 12 Data size: 120 Basic stats: COMPLETE Column stats: NONE
Reduce Output Operator
key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: int)
@@ -694,7 +696,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
Select Operator
- expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 0) + grouping(_col2, 1)) (type: tinyint)
+ expressions: _col0 (type: int), _col1 (type: int), (grouping(_col2, 1) + grouping(_col2, 0)) (type: tinyint)
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 6 Data size: 60 Basic stats: COMPLETE Column stats: NONE
File Output Operator