maropu commented on a change in pull request #32054:
URL: https://github.com/apache/spark/pull/32054#discussion_r609151406



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -305,6 +305,12 @@ trait CheckAnalysis extends PredicateHelper with 
LookupCatalog {
                     s"nor is it an aggregate function. " +
                     "Add to group by or wrap in first() (or first_value) if 
you don't care " +
                     "which value you get.")
+              case s: ScalarSubquery
+                  if s.children.nonEmpty && 
!groupingExprs.exists(_.semanticEquals(s)) =>
+                failAnalysis(s"Correlated scalar subquery '${s.sql}' is 
neither " +
+                  s"present in the group by, nor in an aggregate function. Add 
it to group by " +
+                  s"using ordinal position or wrap it in first() (or 
first_value) if you don't " +
+                  s"care which value you get.")

Review comment:
       Ah, okay. I see. Thanks for your explanation. If so, its okay to leave 
it as it is. Probably, After #31913 resolved, I think we might be able to 
handle this case more safely. That's because the PR is proposing to replace 
group-by exprs with ordinals to aggr exprs.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to