dongjoon-hyun commented on code in PR #60473:
URL: https://github.com/apache/spark/pull/60473#discussion_r4570395953
##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/InvokeProcedures.scala:
##########
@@ -46,6 +46,14 @@ class InvokeProcedures(session: SparkSession) extends
Rule[LogicalPlan] {
session.sessionState.optimizer.execute(c) match {
case Call(ResolvedProcedure(_, _, procedure: BoundProcedure), args, _)
=>
invoke(procedure, args, c)
+ case Call(_, args, _) =>
+ // A rule such as `ExtractPythonUDFs` can add an operator under the
`Call` to evaluate an
+ // argument. Such an argument reads the output of that operator and
does not fold.
+ c.procedure match {
Review Comment:
Thank you, @viirya. Updated as suggested. The procedure is now taken from
`c` once before the optimizer runs, and every other plan goes to one `case
optimized` that throws `INTERNAL_ERROR`. The comment there now says why it
still throws when every argument folds: invoking the procedure would ignore the
operator under the `Call`.
With this change, apache/spark#60392 no longer merges silently. A local
merge simulation conflicts on the first `case` line, so whichever PR lands
later has to update both patterns. I updated the PR description accordingly.
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala:
##########
@@ -111,6 +111,21 @@ class ProcedureSuite extends SharedSparkSession with
BeforeAndAfter {
"paramType" -> toSQLType("INT")))
}
+ test("SPARK-61669: an argument evaluated by an operator under the CALL") {
Review Comment:
Thanks. I added both test cases and moved the IN subquery test case right
after the SPARK-61656 one.
- `SPARK-61669: an argument with a Python UDF` uses
`assume(shouldTestPythonUDFs)` and `TestPythonUDF`, as `JoinSuite` does.
- `SPARK-61669: an operator under the CALL with foldable arguments` adds an
extra optimizer rule that puts `Project(p.output, p)` under the `Call`, and
checks that `CALL cat.ns.sum(1, 2)` still fails with `INTERNAL_ERROR`.
--
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]