cloud-fan commented on a change in pull request #32082:
URL: https://github.com/apache/spark/pull/32082#discussion_r620410980



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1955,20 +1959,29 @@ class Analyzer(override val catalogManager: 
CatalogManager)
    * @see https://issues.apache.org/jira/browse/SPARK-19737
    */
   object LookupFunctions extends Rule[LogicalPlan] {
+    import CatalogV2Implicits._
     override def apply(plan: LogicalPlan): LogicalPlan = {
       val externalFunctionNameSet = new mutable.HashSet[FunctionIdentifier]()
       plan.resolveExpressions {
-        case f: UnresolvedFunction
-          if externalFunctionNameSet.contains(normalizeFuncName(f.name)) => f
-        case f: UnresolvedFunction if 
v1SessionCatalog.isRegisteredFunction(f.name) => f
-        case f: UnresolvedFunction if 
v1SessionCatalog.isPersistentFunction(f.name) =>
-          externalFunctionNameSet.add(normalizeFuncName(f.name))
+        case f @ UnresolvedFunction(NonSessionCatalogAndIdentifier(_, _), _, 
_, _, _) =>

Review comment:
       This makes me feel that it's clearer to write if else, which also saves 
a lot of `AsFunctionIdentifier.unapply` calls.
   ```
   case f @ UnresolvedFunction(CatalogAndIdentifier(catalog, v2Ident), _, ...) 
=>
     if (CatalogV2Util.isSessionCatalog(catalog)) {
       // do nothing for v2 catalog, as we don't have api to check v2 function 
existence
     } else {
       val ident = v2Ident.asFunctionIdentifier
       if (externalFunctionNameSet.contains...) {
         // OK
       } else if ... {
         // OK
       } else if ... else ...
     }
   ```




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

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