srielau commented on code in PR #55523:
URL: https://github.com/apache/spark/pull/55523#discussion_r3144626950


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/resolver/HybridAnalyzer.scala:
##########
@@ -378,6 +378,7 @@ object HybridAnalyzer {
         extensions = legacyAnalyzer.singlePassResolverExtensions,
         metadataResolverExtensions = 
legacyAnalyzer.singlePassMetadataResolverExtensions,
         externalRelationResolution = Some(relationResolution),
+        conf = legacyAnalyzer.resolutionConf,

Review Comment:
   Good catch, agreed. Addressed in 99415fd4d5e: I removed explicit `conf = 
legacyAnalyzer.resolutionConf` from `HybridAnalyzer.fromLegacyAnalyzer`, so the 
resolver reads SQLConf from thread-local under the existing 
`SQLConf.withExistingConf(sessionConf)` scope in analyzer execution.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionResolution.scala:
##########
@@ -592,6 +634,58 @@ class FunctionResolution(
       errorClass = errorClass,
       messageParameters = messageParameters)
   }
+
+  /**
+   * Resolves [[UnresolvedProcedure]] for `CALL` / `DESCRIBE PROCEDURE` using 
the same multipart
+   * candidates as SQL functions and relations ([[resolutionCandidates]] /
+   * [[sqlResolutionPathEntriesForAnalysis]]). Catalogs that do not implement
+   * [[ProcedureCatalog]] are skipped for unqualified names; an explicitly 
catalog-qualified name
+   * that targets a non-[[ProcedureCatalog]] still raises
+   * [[QueryCompilationErrors.missingCatalogProceduresAbilityError]].
+   */
+  def resolveProcedure(unresolved: UnresolvedProcedure): LogicalPlan = {
+    val candidates = resolutionCandidates(unresolved.nameParts)
+    for (multipart <- candidates) {
+      val expandedOpt =
+        try {
+          Some(relationResolution.expandIdentifier(multipart))
+        } catch {
+          case NonFatal(_) => None
+        }
+      expandedOpt.foreach { expanded =>
+        CatalogAndIdentifier.unapply(expanded).foreach { case (catalog, ident) 
=>
+          catalog match {
+            case pc: ProcedureCatalog =>
+              try {
+                val procedure = pc.loadProcedure(ident)
+                return ResolvedProcedure(pc, ident, procedure)
+              } catch {
+                case e: AnalysisException => throw e
+                case e: SparkThrowable => throw e
+                case NonFatal(e) =>
+                  val cause = e match {
+                    case ex: Exception => ex
+                    case th => new RuntimeException(th)
+                  }
+                  throw QueryCompilationErrors.failedToLoadRoutineError(
+                    catalog.name +: ident.asMultipartIdentifier,
+                    cause)

Review Comment:
   Addressed in 99415fd4d5e. For unqualified procedure names, candidate load 
failures are now treated as misses and PATH iteration continues (matching 
table/function behavior). Explicitly catalog-qualified behavior is unchanged. 
Added regression test: `ProcedureSuite` test "PATH enabled: unqualified CALL 
skips missing candidate and keeps searching".



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/v2ResolutionPlans.scala:
##########
@@ -68,15 +68,39 @@ case class UnresolvedView(
     allowTemp: Boolean,
     suggestAlternative: Boolean = false) extends UnresolvedLeafNode
 
+/**
+ * Controls which search path is shown in `TABLE_OR_VIEW_NOT_FOUND` for
+ * [[UnresolvedTableOrView]] (see 
[[org.apache.spark.sql.catalyst.analysis.CheckAnalysis]]).
+ */
+sealed trait UnresolvedTableOrViewSearchPathMode
+
+object UnresolvedTableOrViewSearchPathMode {
+  /** DDL on catalog objects: `system.session` and current catalog namespace 
only. */
+  case object Ddl extends UnresolvedTableOrViewSearchPathMode
+  /**
+   * Like `SELECT` / DML: full `sqlResolutionPathEntries` order; fully 
qualified
+   * `system.session.*` names still use the temp-view-only path in errors.
+   */
+  case object QueryLike extends UnresolvedTableOrViewSearchPathMode
+  /** Commands that only target temp views (e.g. some `DROP TEMPORARY VIEW` 
paths). */
+  case object TempViewOnly extends UnresolvedTableOrViewSearchPathMode

Review Comment:
   Addressed in 99415fd4d5e. Removed dead `TempViewOnly` enum case and its 
`CheckAnalysis` match arm since it has no callers.



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