You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ke...@apache.org on 2012/05/09 18:31:39 UTC
svn commit: r1336284 - in /hive/trunk/ql/src:
java/org/apache/hadoop/hive/ql/parse/ test/queries/clientnegative/
test/results/clientnegative/
Author: kevinwilfong
Date: Wed May 9 16:31:39 2012
New Revision: 1336284
URL: http://svn.apache.org/viewvc?rev=1336284&view=rev
Log:
HIVE-2956 Provide error message when using UDAF in the place of UDF instead of throwing NPE (navis via kevinwilfong)
Added:
hive/trunk/ql/src/test/queries/clientnegative/udaf_invalid_place.q
hive/trunk/ql/src/test/queries/clientnegative/udtf_invalid_place.q
hive/trunk/ql/src/test/results/clientnegative/udaf_invalid_place.q.out
hive/trunk/ql/src/test/results/clientnegative/udtf_invalid_place.q.out
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java?rev=1336284&r1=1336283&r2=1336284&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java Wed May 9 16:31:39 2012
@@ -130,6 +130,7 @@ public enum ErrorMsg {
UDTF_NO_DISTRIBUTE_BY("DISTRUBTE BY is not supported with a UDTF in the SELECT clause"),
UDTF_INVALID_LOCATION("UDTF's are not supported outside the SELECT clause, nor nested "
+ "in expressions"),
+ UDAF_INVALID_LOCATION("Not yet supported place for UDAF"),
UDTF_LATERAL_VIEW("UDTF's cannot be in a select expression when there is a lateral view"),
UDTF_ALIAS_MISMATCH("The number of aliases supplied in the AS clause does not match the "
+ "number of columns output by the UDTF"),
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java?rev=1336284&r1=1336283&r2=1336284&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java Wed May 9 16:31:39 2012
@@ -684,6 +684,15 @@ public final class TypeCheckProcFactory
if (fi.getGenericUDTF() != null) {
throw new SemanticException(ErrorMsg.UDTF_INVALID_LOCATION.getMsg());
}
+ // UDAF in filter condition, group-by caluse, param of funtion, etc.
+ if (fi.getGenericUDAFResolver() != null) {
+ if (isFunction) {
+ throw new SemanticException(ErrorMsg.UDAF_INVALID_LOCATION.
+ getMsg((ASTNode) expr.getChild(0)));
+ } else {
+ throw new SemanticException(ErrorMsg.UDAF_INVALID_LOCATION.getMsg(expr));
+ }
+ }
if (!ctx.getAllowStatefulFunctions() && (fi.getGenericUDF() != null)) {
if (FunctionRegistry.isStateful(fi.getGenericUDF())) {
throw new SemanticException(
Added: hive/trunk/ql/src/test/queries/clientnegative/udaf_invalid_place.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/udaf_invalid_place.q?rev=1336284&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/udaf_invalid_place.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/udaf_invalid_place.q Wed May 9 16:31:39 2012
@@ -0,0 +1 @@
+select distinct key, sum(key) from src;
Added: hive/trunk/ql/src/test/queries/clientnegative/udtf_invalid_place.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/udtf_invalid_place.q?rev=1336284&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/udtf_invalid_place.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/udtf_invalid_place.q Wed May 9 16:31:39 2012
@@ -0,0 +1 @@
+select distinct key, explode(key) from src;
Added: hive/trunk/ql/src/test/results/clientnegative/udaf_invalid_place.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/udaf_invalid_place.q.out?rev=1336284&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/udaf_invalid_place.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/udaf_invalid_place.q.out Wed May 9 16:31:39 2012
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: Line 1:21 Not yet supported place for UDAF 'sum'
Added: hive/trunk/ql/src/test/results/clientnegative/udtf_invalid_place.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/udtf_invalid_place.q.out?rev=1336284&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/udtf_invalid_place.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/udtf_invalid_place.q.out Wed May 9 16:31:39 2012
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: UDTF's are not supported outside the SELECT clause, nor nested in expressions