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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionResolution.scala:
##########
@@ -370,7 +355,14 @@ class FunctionResolution(
     if (nameParts.length == 1) {
       // Must match [[resolutionCandidates]] / [[resolveFunction]]: 
single-part names use PATH +
       // session order, not only the current namespace (LookupCatalog 
single-part rule).
-      for (candidate <- resolutionCandidates(nameParts)) {
+      // `system.*` candidates are handled by [[lookupBuiltinOrTempFunction]] /
+      // [[lookupBuiltinOrTempTableFunction]] above; skip them here to avoid 
redundant
+      // catalog calls.
+      val persistentCandidates = resolutionCandidates(nameParts).filterNot { c 
=>
+        c.length >= 2 &&
+          c.head.equalsIgnoreCase(CatalogManager.SYSTEM_CATALOG_NAME)
+      }

Review Comment:
   Tightened in c2f8f642c45. The filter now matches the actually-resolved set 
(`system.session`, `system.builtin`) rather than any prefix beginning with 
`system`:
   
   ```scala
   val persistentCandidates = resolutionCandidates(nameParts).filterNot { c =>
     c.length >= 2 &&
       c.head.equalsIgnoreCase(CatalogManager.SYSTEM_CATALOG_NAME) && {
         val ns = c(1)
         ns.equalsIgnoreCase(CatalogManager.SESSION_NAMESPACE) ||
           ns.equalsIgnoreCase(CatalogManager.BUILTIN_NAMESPACE)
       }
   }
   ```
   
   That tracks exactly what `identifierFromSystemNameParts` accepts (and 
therefore what `lookupBuiltinOrTempFunction` / 
`lookupBuiltinOrTempTableFunction` actually resolved earlier). A future 
`system.<x>` namespace not covered by `identifierFromSystemNameParts` will fall 
through to persistent lookup as expected. Comment updated to reflect the 
rationale ("redundancy reason" rather than "prefix").



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