You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2017/03/08 03:29:23 UTC
[45/50] [abbrv] hive git commit: HIVE-16064 : Allow ALL set
quantifier with aggregate functions (Vineet Garg via Ashutosh Chauhan)
HIVE-16064 : Allow ALL set quantifier with aggregate functions (Vineet Garg via Ashutosh Chauhan)
Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/971896c5
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/971896c5
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/971896c5
Branch: refs/heads/hive-14535
Commit: 971896c58c3b3e5cd3b77b6a87cc072ebdd55e47
Parents: 14f6f16
Author: Vineet Garg <vg...@hortonworks.com>
Authored: Tue Mar 7 14:05:16 2017 -0800
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Tue Mar 7 14:06:19 2017 -0800
----------------------------------------------------------------------
.../test/resources/testconfiguration.properties | 1 +
.../hadoop/hive/ql/parse/IdentifiersParser.g | 2 +-
.../queries/clientpositive/udaf_all_keyword.q | 28 ++++
.../clientpositive/llap/udaf_all_keyword.q.out | 135 +++++++++++++++++++
4 files changed, 165 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/971896c5/itests/src/test/resources/testconfiguration.properties
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties
index b01ebd8..9babc77 100644
--- a/itests/src/test/resources/testconfiguration.properties
+++ b/itests/src/test/resources/testconfiguration.properties
@@ -600,6 +600,7 @@ minillaplocal.query.files=acid_globallimit.q,\
tez_vector_dynpart_hashjoin_2.q,\
uber_reduce.q,\
udaf_collect_set_2.q,\
+ udaf_all_keyword.q,\
union_fast_stats.q,\
union_remove_26.q,\
union_top_level.q,\
http://git-wip-us.apache.org/repos/asf/hive/blob/971896c5/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
index 0de1596..c3d3c91 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
@@ -214,7 +214,7 @@ function
LPAREN
(
(STAR) => (star=STAR)
- | (dist=KW_DISTINCT)? (selectExpression (COMMA selectExpression)*)?
+ | (dist=KW_DISTINCT | KW_ALL)? (selectExpression (COMMA selectExpression)*)?
)
RPAREN (KW_OVER ws=window_specification)?
-> {$star != null}? ^(TOK_FUNCTIONSTAR functionName $ws?)
http://git-wip-us.apache.org/repos/asf/hive/blob/971896c5/ql/src/test/queries/clientpositive/udaf_all_keyword.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/udaf_all_keyword.q b/ql/src/test/queries/clientpositive/udaf_all_keyword.q
new file mode 100644
index 0000000..e542621
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/udaf_all_keyword.q
@@ -0,0 +1,28 @@
+-- following tests are to test ALL quantifier (HIVE-16064)
+
+-- count
+select count(ALL 1) from src;
+select count(ALL key) from src;
+-- count(all) and count() should return same value
+select count(ALL key) = count(key) from src;
+
+-- AVG
+select AVG(ALL 1) from src;
+select AVG(ALL key) from src;
+select AVG(ALL key) = AVG(key) from src;
+
+-- MIN
+select MIN(ALL 1) from src;
+select MIN(ALL key) from src;
+select MIN(ALL key) = MIN(key) from src;
+
+-- MAX
+select MAX(ALL 1) from src;
+select MAX(ALL key) from src;
+select MAX(ALL key) = MAX(key) from src;
+
+-- SUM
+select SUM(ALL 1) from src;
+select SUM(ALL key) from src;
+select SUM(ALL key) = SUM(key) from src;
+
http://git-wip-us.apache.org/repos/asf/hive/blob/971896c5/ql/src/test/results/clientpositive/llap/udaf_all_keyword.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/udaf_all_keyword.q.out b/ql/src/test/results/clientpositive/llap/udaf_all_keyword.q.out
new file mode 100644
index 0000000..1cca4a3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/udaf_all_keyword.q.out
@@ -0,0 +1,135 @@
+PREHOOK: query: select count(ALL 1) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select count(ALL 1) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+500
+PREHOOK: query: select count(ALL key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select count(ALL key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+500
+PREHOOK: query: select count(ALL key) = count(key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select count(ALL key) = count(key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+true
+PREHOOK: query: select AVG(ALL 1) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select AVG(ALL 1) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+1.0
+PREHOOK: query: select AVG(ALL key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select AVG(ALL key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+260.182
+PREHOOK: query: select AVG(ALL key) = AVG(key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select AVG(ALL key) = AVG(key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+true
+PREHOOK: query: select MIN(ALL 1) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select MIN(ALL 1) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+1
+PREHOOK: query: select MIN(ALL key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select MIN(ALL key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+0
+PREHOOK: query: select MIN(ALL key) = MIN(key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select MIN(ALL key) = MIN(key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+true
+PREHOOK: query: select MAX(ALL 1) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select MAX(ALL 1) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+1
+PREHOOK: query: select MAX(ALL key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select MAX(ALL key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+98
+PREHOOK: query: select MAX(ALL key) = MAX(key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select MAX(ALL key) = MAX(key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+true
+PREHOOK: query: select SUM(ALL 1) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select SUM(ALL 1) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+500
+PREHOOK: query: select SUM(ALL key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select SUM(ALL key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+130091.0
+PREHOOK: query: select SUM(ALL key) = SUM(key) from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select SUM(ALL key) = SUM(key) from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+true