Repository: hive
Updated Branches:
  refs/heads/master eb293245d -> 16f2c77fc


HIVE-12570 : Incorrect error message Expression not in GROUP BY key thrown 
instead of Invalid function (Hari Subramaniyan, reviewed by Laljo John 
Pullokkaran)


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

Branch: refs/heads/master
Commit: 16f2c77fc7469c45c565366ced3e3be95146f92c
Parents: eb29324
Author: Hari Subramaniyan <[email protected]>
Authored: Mon Dec 14 16:10:39 2015 -0800
Committer: Hari Subramaniyan <[email protected]>
Committed: Mon Dec 14 16:10:39 2015 -0800

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java   | 4 ++++
 ql/src/test/queries/clientnegative/invalid_select_fn.q           | 1 +
 ql/src/test/results/clientnegative/invalid_select_fn.q.out       | 1 +
 ql/src/test/results/clientnegative/udf_invalid.q.out             | 2 +-
 ql/src/test/results/compiler/errors/unknown_function1.q.out      | 2 +-
 ql/src/test/results/compiler/errors/unknown_function4.q.out      | 2 +-
 6 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/16f2c77f/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 945a6d7..27549dc 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
@@ -531,6 +531,10 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer 
{
       if (expressionTree.getChild(0).getType() == HiveParser.Identifier) {
         String functionName = unescapeIdentifier(expressionTree.getChild(0)
             .getText());
+        // Validate the function name
+        if (FunctionRegistry.getFunctionInfo(functionName) == null) {
+          throw new 
SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(functionName));
+        }
         if(FunctionRegistry.impliesOrder(functionName)) {
           throw new 
SemanticException(ErrorMsg.MISSING_OVER_CLAUSE.getMsg(functionName));
         }

http://git-wip-us.apache.org/repos/asf/hive/blob/16f2c77f/ql/src/test/queries/clientnegative/invalid_select_fn.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/invalid_select_fn.q 
b/ql/src/test/queries/clientnegative/invalid_select_fn.q
new file mode 100644
index 0000000..b01d29b
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/invalid_select_fn.q
@@ -0,0 +1 @@
+explain create table src_invalid as select average(key) as key_avg from src 
group by value;

http://git-wip-us.apache.org/repos/asf/hive/blob/16f2c77f/ql/src/test/results/clientnegative/invalid_select_fn.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/invalid_select_fn.q.out 
b/ql/src/test/results/clientnegative/invalid_select_fn.q.out
new file mode 100644
index 0000000..6023f55
--- /dev/null
+++ b/ql/src/test/results/clientnegative/invalid_select_fn.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException [Error 10011]: Invalid function average

http://git-wip-us.apache.org/repos/asf/hive/blob/16f2c77f/ql/src/test/results/clientnegative/udf_invalid.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/udf_invalid.q.out 
b/ql/src/test/results/clientnegative/udf_invalid.q.out
index c394cc8..29b6cc3 100644
--- a/ql/src/test/results/clientnegative/udf_invalid.q.out
+++ b/ql/src/test/results/clientnegative/udf_invalid.q.out
@@ -1 +1 @@
-FAILED: SemanticException Line 0:-1 Invalid function 'default.nonexistfunc'
+FAILED: SemanticException [Error 10011]: Invalid function default.nonexistfunc

http://git-wip-us.apache.org/repos/asf/hive/blob/16f2c77f/ql/src/test/results/compiler/errors/unknown_function1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/compiler/errors/unknown_function1.q.out 
b/ql/src/test/results/compiler/errors/unknown_function1.q.out
index c6af515..8e1343b 100644
--- a/ql/src/test/results/compiler/errors/unknown_function1.q.out
+++ b/ql/src/test/results/compiler/errors/unknown_function1.q.out
@@ -1,2 +1,2 @@
 Semantic Exception: 
-Line 2:44 Invalid function 'dummyfn'
\ No newline at end of file
+Invalid function dummyfn
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/16f2c77f/ql/src/test/results/compiler/errors/unknown_function4.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/compiler/errors/unknown_function4.q.out 
b/ql/src/test/results/compiler/errors/unknown_function4.q.out
index c6af515..8e1343b 100644
--- a/ql/src/test/results/compiler/errors/unknown_function4.q.out
+++ b/ql/src/test/results/compiler/errors/unknown_function4.q.out
@@ -1,2 +1,2 @@
 Semantic Exception: 
-Line 2:44 Invalid function 'dummyfn'
\ No newline at end of file
+Invalid function dummyfn
\ No newline at end of file

Reply via email to