File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
sql/hive/src/main/scala/org/apache/spark/sql/hive Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,9 @@ private[hive] object HiveQl {
204204 class ParseException (sql : String , cause : Throwable )
205205 extends Exception (s " Failed to parse: $sql" , cause)
206206
207+ class SemanticException (msg : String )
208+ extends Exception (msg)
209+
207210 /**
208211 * Returns the AST for the given SQL string.
209212 */
@@ -579,6 +582,11 @@ private[hive] object HiveQl {
579582 if (selectDistinctClause.isDefined) Distinct (withProject) else withProject
580583
581584 val withHaving = havingClause.map { h =>
585+
586+ if (groupByClause == None ) {
587+ throw new SemanticException (" Error in semantic analysis: HAVING specified without GROUP BY" )
588+ }
589+
582590 val Seq (havingExpr) = h.getChildren.toSeq
583591 Filter (nodeToExpr(havingExpr), withDistinct)
584592 }.getOrElse(withDistinct)
You can’t perform that action at this time.
0 commit comments