dtenedor commented on code in PR #37840:
URL: https://github.com/apache/spark/pull/37840#discussion_r971397869


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -823,12 +834,16 @@ trait CheckAnalysis extends PredicateHelper with 
LookupCatalog {
               // it must also be in the aggregate expressions to be rewritten 
in the optimization
               // phase.
               if (containsExpr(a.groupingExpressions) && 
!containsExpr(a.aggregateExpressions)) {
-                failAnalysis("Correlated scalar subqueries in the group by 
clause " +
-                  s"must also be in the aggregate expressions:\n$a")
+                a.failAnalysis(
+                  errorClass = "UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY",
+                  errorSubClass = "MUST_AGGREGATE_CORRELATED_SCALAR_SUBQUERY",
+                  treeNodes = Seq(a))

Review Comment:
   Good Q. The way I implemented it, `a` is a `TreeNode`. This overload of 
`failAnalysis` I added takes a `Seq[TreeNode[_]]` and then assigns their 
`toString`s to the `treeNode` parameter. I do this in the `failAnalysis` 
overload itself in order to normalize the expression IDs in the string to keep 
tests deterministic (the LogicalPlan `canonicalized` method aims to support 
this as well, but is not available during analysis since it uses `transformUp`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to