Index: ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (revision 1167000) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (working copy) @@ -186,6 +186,7 @@ NO_COMPARE_BIGINT_DOUBLE("In strict mode, comparing bigints and doubles is not allowed, " + "it may result in a loss of precision. " + "If you really want to perform the operation, set hive.mapred.mode=nonstrict"), + FUNCTIONS_ARE_NOT_SUPPORTED_IN_ORDER_BY("functions are not supported in order by"), ; private String mesg; Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 1167000) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -4524,6 +4524,9 @@ // ClusterBy order.append("+"); } + if (cl.getType() == HiveParser.TOK_FUNCTION) { + throw new SemanticException(ErrorMsg.FUNCTIONS_ARE_NOT_SUPPORTED_IN_ORDER_BY.getMsg()); + } ExprNodeDesc exprNode = genExprNodeDesc(cl, inputRR); sortCols.add(exprNode); } Index: ql/src/test/queries/clientnegative/orderby_function.q =================================================================== --- ql/src/test/queries/clientnegative/orderby_function.q (revision 0) +++ ql/src/test/queries/clientnegative/orderby_function.q (revision 0) @@ -0,0 +1 @@ +select src.key FROM src ORDER BY count(1) limit 1; Index: ql/src/test/results/clientnegative/orderby_function.q.out =================================================================== --- ql/src/test/results/clientnegative/orderby_function.q.out (revision 0) +++ ql/src/test/results/clientnegative/orderby_function.q.out (revision 0) @@ -0,0 +1 @@ +FAILED: Error in semantic analysis: functions are not supported in order by