diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java --- ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java @@ -131,6 +131,7 @@ public enum ErrorMsg { 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"), + UDAF_INVALID_LOCATION("Nested UDAFs not supported"), UDF_STATEFUL_INVALID_LOCATION("Stateful UDF's can only be invoked in the SELECT list"), LATERAL_VIEW_WITH_JOIN("JOIN with a LATERAL VIEW is not supported"), LATERAL_VIEW_INVALID_CHILD("LATERAL VIEW AST with invalid child"), diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java --- ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java @@ -646,6 +646,10 @@ public final class TypeCheckProcFactory { if (fi.getGenericUDTF() != null) { throw new SemanticException(ErrorMsg.UDTF_INVALID_LOCATION.getMsg()); } + // Detect nested UDAF as they aren't supported + if (fi.getGenericUDAFResolver() != null) { + throw new SemanticException(ErrorMsg.UDAF_INVALID_LOCATION.getMsg()); + } if (!ctx.getAllowStatefulFunctions() && (fi.getGenericUDF() != null)) { if (FunctionRegistry.isStateful(fi.getGenericUDF())) { throw new SemanticException( diff --git ql/src/test/queries/clientnegative/udaf_not_supported1.q ql/src/test/queries/clientnegative/udaf_not_supported1.q --- ql/src/test/queries/clientnegative/udaf_not_supported1.q +++ ql/src/test/queries/clientnegative/udaf_not_supported1.q @@ -0,0 +1 @@ +SELECT avg(avg(src.key)) FROM src; diff --git ql/src/test/results/clientnegative/udaf_not_supported1.q.out ql/src/test/results/clientnegative/udaf_not_supported1.q.out --- ql/src/test/results/clientnegative/udaf_not_supported1.q.out +++ ql/src/test/results/clientnegative/udaf_not_supported1.q.out @@ -0,0 +1 @@ +FAILED: Error in semantic analysis: Nested UDAFs not supported