dongjoon-hyun commented on code in PR #60632:
URL: https://github.com/apache/spark/pull/60632#discussion_r4607653850


##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/InvokeProcedures.scala:
##########
@@ -39,10 +39,12 @@ class InvokeProcedures(session: SparkSession) extends 
Rule[LogicalPlan] {
   }
 
   private def invokeProcedures(plan: LogicalPlan): LogicalPlan = plan 
resolveOperators {
-    // A CALL with an IN or correlated EXISTS subquery in an argument is left 
for CheckAnalysis to
-    // reject. The optimizer would rewrite the subquery into a join under the 
`Call`.
+    // A CALL with an IN or correlated EXISTS subquery, or an aggregate, 
window function or
+    // generator, in an argument is left for CheckAnalysis to reject. The 
optimizer would rewrite
+    // the subquery into a join under the `Call`, or could fold away the other 
expressions.
     case c: Call if c.resolved && c.bound && c.execute && 
c.checkArgTypes().isSuccess &&
-        !c.args.exists(SubqueryExpression.hasInOrCorrelatedExistsSubquery) =>
+        !c.args.exists(SubqueryExpression.hasInOrCorrelatedExistsSubquery) &&
+        PlanHelper.specialExpressionsInUnsupportedOperator(c).isEmpty =>

Review Comment:
   Good catch, confirmed: `row_number() > 0` and `lag(1) > 0` invoke the 
procedure even with plan change validation on, and 
`grouping(1)`/`grouping_id()` invoke it with validation off. Added a private 
predicate next to the guard that matches the two CheckAnalysis conditions (a 
`Grouping`/`GroupingID` node anywhere in an argument, and a `WindowFunction` 
that is a direct child of a non-`WindowExpression`). A window function as a 
whole argument is left alone and still fails with `NON_FOLDABLE_ARGUMENT`. The 
test now covers both forms and that case. Fixed in the next commit pushed to 
this PR.



##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/InvokeProcedures.scala:
##########
@@ -39,10 +39,12 @@ class InvokeProcedures(session: SparkSession) extends 
Rule[LogicalPlan] {
   }
 
   private def invokeProcedures(plan: LogicalPlan): LogicalPlan = plan 
resolveOperators {
-    // A CALL with an IN or correlated EXISTS subquery in an argument is left 
for CheckAnalysis to
-    // reject. The optimizer would rewrite the subquery into a join under the 
`Call`.
+    // A CALL with an IN or correlated EXISTS subquery, or an aggregate, 
window function or
+    // generator, in an argument is left for CheckAnalysis to reject. The 
optimizer would rewrite

Review Comment:
   Agreed. The comment now says the analyzer rejects it, and the PR title says 
"during analysis" instead of "in CheckAnalysis".



-- 
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: [email protected]

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