Anurag Mantripragada created SPARK-61506:
--------------------------------------------

             Summary: Mark a CALL as bound only after BindProcedures binds it
                 Key: SPARK-61506
                 URL: https://issues.apache.org/jira/browse/SPARK-61506
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 5.0.0
            Reporter: Anurag Mantripragada


CALL fails, or silently ignores arguments, when the procedure implements both 
UnboundProcedure and BoundProcedure (for example a SimpleProcedure, or 
Iceberg's procedures) and an argument is resolved later in the analyzer 
iteration than BindProcedures.

Call.bound is derived from the procedure type, so such a procedure counts as 
bound before BindProcedures has called bind(), rearranged the arguments and 
filled in defaults. ProcedureArgumentCoercion and InvokeProcedures then see the 
arguments as written. With p(ts TIMESTAMP, label STRING DEFAULT 'none') 
implemented as a SimpleProcedure:

{code:sql}
CALL cat.ns.p(TIMESTAMP '2026-01-02 00:00:00' - INTERVAL '1' DAY)
-- IllegalArgumentException: requirement failed: number of args and params must 
match after binding
CALL cat.ns.p(label => 'x', ts => TIMESTAMP '2026-01-02 00:00:00' - INTERVAL 
'1' DAY)
-- IllegalArgumentException: requirement failed: args must be foldable
CALL cat.ns.p(TIMESTAMP '2026-01-02 00:00:00' - INTERVAL '1' DAY, 'x', 1)
-- runs and ignores the third argument instead of failing with WRONG_NUM_ARGS
{code}

The same happens for scalar subquery arguments and time zone dependent 
expressions such as CAST('...' AS TIMESTAMP). If bind() returns a different 
object, Spark also calls call() on the object that was never bound, and EXPLAIN 
CALL binds it on every iteration until it reaches the iteration limit.

Affected since 4.0.0 for procedures implementing both interfaces, and since 
4.2.0 for SimpleProcedure.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to