dongjoon-hyun opened a new pull request, #60396: URL: https://github.com/apache/spark/pull/60396
### What changes were proposed in this pull request? This PR aims to fix `FunctionResolution.resolveProcedure` to treat `null` from `ProcedureCatalog.loadProcedure` as a procedure that is not found, instead of resolving the name to `ResolvedProcedure(catalog, ident, null)`. - An unqualified name moves on to the next entry of the SQL path, as it does when `loadProcedure` throws. - A qualified name fails with the existing `UNRESOLVED_ROUTINE` error. ### Why are the changes needed? `ProcedureCatalog.loadProcedure` does not specify what happens when the procedure does not exist. When a connector returns `null` instead of throwing, the analyzer keeps the `null` procedure. - `BindProcedures` skips it because its type pattern does not match `null`, and `CheckAnalysis` checks only a bound `CALL`. So `CALL cat.ns.missing()` passes the analysis and invokes nothing. An action on the result fails with an `UnsupportedOperationException` without a message from `ExplainOnlySparkPlan.doExecute`. - For an unqualified name, the search stops at the first path entry whose catalog returns `null`, so a procedure in a later path entry is never found. - `DESC PROCEDURE cat.ns.missing` fails with `INTERNAL_ERROR` (`Invalid procedure identifier`). This PR keeps the `ProcedureCatalog` API as it is. Spark has no procedure-specific not-found exception, and existing connectors such as Apache Iceberg's `BaseCatalog` throw an exception for an unknown procedure. So this is a defensive fix in the analyzer. ### Does this PR introduce _any_ user-facing change? Yes, only for a connector whose `loadProcedure` returns `null` for an unknown procedure. Connectors that throw an exception are not affected. | Statement | BEFORE | AFTER | |---|---|---| | `CALL cat.ns.missing()` | No error, nothing is invoked, and an action fails with `UnsupportedOperationException` | `UNRESOLVED_ROUTINE` | | `CALL sum(1, 2)` after `SET PATH = cat.ns_miss, cat2.ns_hit` | Stops at `cat.ns_miss`, and an action fails with `UnsupportedOperationException` | Invokes `cat2.ns_hit.sum` | | `DESC PROCEDURE cat.ns.missing` | `INTERNAL_ERROR` | `UNRESOLVED_ROUTINE` | ### How was this patch tested? Pass the CIs with the newly added test case in `ProcedureSuite`. It uses a test catalog whose `loadProcedure` returns `null` for an unknown procedure, and fails without this patch. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 -- 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]
