hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject hive git commit: HIVE-13000 : Hive returns useless parsing error (Alina Abramova via Ashutosh Chauhan)
Date Thu, 04 Jan 2018 18:25:38 GMT
Repository: hive
Updated Branches:
  refs/heads/master 841081a9c -> 77360d6cf


HIVE-13000 : Hive returns useless parsing error (Alina Abramova via Ashutosh Chauhan)

Signed-off-by: Ashutosh Chauhan <hashutosh@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/77360d6c
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/77360d6c
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/77360d6c

Branch: refs/heads/master
Commit: 77360d6cfbcef2b905bf6500374f2f23d5bb2803
Parents: 841081a
Author: Alina Abramova <aline.abramova@gmail.com>
Authored: Tue Nov 8 10:37:00 2016 -0800
Committer: Ashutosh Chauhan <hashutosh@apache.org>
Committed: Thu Jan 4 10:25:27 2018 -0800

----------------------------------------------------------------------
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java       | 12 ++++++++++--
 ql/src/test/queries/clientnegative/groupby_struct.q  |  6 ++++++
 .../test/results/clientnegative/groupby_struct.q.out | 15 +++++++++++++++
 .../results/compiler/errors/nonkey_groupby.q.out     |  2 +-
 4 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/77360d6c/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 10fe6fc..5a88a96 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
@@ -12025,8 +12025,16 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
         TypeCheckProcFactory.genExprNode(expr, tcCtx);
     ExprNodeDesc desc = nodeOutputs.get(expr);
     if (desc == null) {
-      String errMsg = tcCtx.getError();
-      if (errMsg == null) {
+        String tableOrCol = BaseSemanticAnalyzer.unescapeIdentifier(expr
+            .getChild(0).getText());
+        ColumnInfo colInfo = input.get(null, tableOrCol);
+        String errMsg;
+        if (colInfo == null && input.getIsExprResolver()){
+            errMsg = ErrorMsg.NON_KEY_EXPR_IN_GROUPBY.getMsg(expr);
+        } else {
+            errMsg = tcCtx.getError();
+        }
+        if (errMsg == null) {
         errMsg = "Error in parsing ";
       }
       throw new SemanticException(errMsg);

http://git-wip-us.apache.org/repos/asf/hive/blob/77360d6c/ql/src/test/queries/clientnegative/groupby_struct.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/groupby_struct.q b/ql/src/test/queries/clientnegative/groupby_struct.q
new file mode 100644
index 0000000..99bbdaf
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/groupby_struct.q
@@ -0,0 +1,6 @@
+CREATE TABLE addresses (
+    name float,
+    address struct<intVals:int,strVals:string>
+ );
+
+SELECT address FROM addresses GROUP BY address.intVals;

http://git-wip-us.apache.org/repos/asf/hive/blob/77360d6c/ql/src/test/results/clientnegative/groupby_struct.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/groupby_struct.q.out b/ql/src/test/results/clientnegative/groupby_struct.q.out
new file mode 100644
index 0000000..f62dbfe
--- /dev/null
+++ b/ql/src/test/results/clientnegative/groupby_struct.q.out
@@ -0,0 +1,15 @@
+PREHOOK: query: CREATE TABLE addresses (
+    name float,
+    address struct<intVals:int,strVals:string>
+ )
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@addresses
+POSTHOOK: query: CREATE TABLE addresses (
+    name float,
+    address struct<intVals:int,strVals:string>
+ )
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@addresses
+FAILED: SemanticException [Error 10025]: Line 3:7 Expression not in GROUP BY key 'address'

http://git-wip-us.apache.org/repos/asf/hive/blob/77360d6c/ql/src/test/results/compiler/errors/nonkey_groupby.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/compiler/errors/nonkey_groupby.q.out b/ql/src/test/results/compiler/errors/nonkey_groupby.q.out
index 9dfbb97..a13d45d 100644
--- a/ql/src/test/results/compiler/errors/nonkey_groupby.q.out
+++ b/ql/src/test/results/compiler/errors/nonkey_groupby.q.out
@@ -1,2 +1,2 @@
 Semantic Exception: 
-Line 2:48 Invalid column reference 'value'
\ No newline at end of file
+Line 2:44 Expression not in GROUP BY key 'value'
\ No newline at end of file


Mime
View raw message