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


##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/InvokeProcedures.scala:
##########
@@ -39,7 +39,10 @@ class InvokeProcedures(session: SparkSession) extends 
Rule[LogicalPlan] {
   }
 
   private def invokeProcedures(plan: LogicalPlan): LogicalPlan = plan 
resolveOperators {
-    case c: Call if c.resolved && c.bound && c.execute && 
c.checkArgTypes().isSuccess =>
+    // 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`.
+    case c: Call if c.resolved && c.bound && c.execute && 
c.checkArgTypes().isSuccess &&
+        !c.args.exists(SubqueryExpression.hasInOrCorrelatedExistsSubquery) =>

Review Comment:
   Thank you for the review, @viirya. I confirmed that the nested case still 
fails with `INTERNAL_ERROR` with this PR.
   
   A Python UDF argument fails with the same `INTERNAL_ERROR` on master, too, 
because `ExtractPythonUDFs` puts a `BatchEvalPython` under the `Call`. Since a 
`Call` exception in `RewritePredicateSubquery` doesn't cover it, I'd like to 
handle both in `InvokeProcedures` instead: when the child of the optimized 
`Call` is not the procedure, throw `NON_FOLDABLE_ARGUMENT` for the first 
non-foldable argument. That gives the nested case the same error as your 
suggestion, without adding a `Call` exception to each rule. I'll file a new 
JIRA issue for it and note it in the PR description.
   



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