dongjoon-hyun commented on code in PR #60396:
URL: https://github.com/apache/spark/pull/60396#discussion_r4560812615
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala:
##########
@@ -241,6 +241,28 @@ class ProcedureSuite extends SharedSparkSession with
BeforeAndAfter {
}
}
+ test("SPARK-61553: a null from loadProcedure means the procedure is not
found") {
+ withSQLConf("spark.sql.catalog.nullcat" ->
classOf[NullReturningProcedureCatalog].getName) {
+ checkError(
+ exception = intercept[AnalysisException](sql("CALL
nullcat.ns.missing()")),
+ condition = "UNRESOLVED_ROUTINE",
+ parameters = Map(
+ "routineName" -> "`nullcat`.`ns`.`missing`",
+ "searchPath" -> "[`system`.`builtin`, `system`.`session`,
`spark_catalog`.`default`]"),
+ context = ExpectedContext(fragment = "CALL nullcat.ns.missing()",
start = 0, stop = 24))
Review Comment:
Thank you. I added `DESC PROCEDURE nullcat.ns.missing` to the test.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionResolution.scala:
##########
@@ -873,7 +873,11 @@ class FunctionResolution(
case pc: ProcedureCatalog =>
try {
val procedure = pc.loadProcedure(ident)
- return ResolvedProcedure(pc, ident, procedure)
+ // A null means the catalog has no such procedure. Treat it as
a miss, so an
+ // unqualified name keeps searching PATH and a qualified one
fails as unresolved.
+ if (procedure != null) {
Review Comment:
Thank you for the suggestion. I'd like to keep the Javadoc as it is in this
PR.
- If it documents `null` as the not-found result, a connector that follows
it does nothing silently on the released Spark versions without this fix.
- If it asks connectors to throw instead, there is no procedure-specific
exception yet, and a generic exception becomes `FAILED_TO_LOAD_ROUTINE` for a
qualified name.
So I think the contract needs a dedicated exception type, which is beyond
this defensive fix.
--
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]