planga82 commented on a change in pull request #26890: [SPARK-30039][SQL] 
CREATE FUNCTION should do multi-catalog resolution
URL: https://github.com/apache/spark/pull/26890#discussion_r358006484
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##########
 @@ -475,47 +475,45 @@ class ResolveSessionCatalog(
         propertyKey)
 
     case DescribeFunctionStatement(CatalogAndIdentifier(catalog, 
functionIdent), extended) =>
-      val functionIdentifier = if (isSessionCatalog(catalog)) {
-        functionIdent.asMultipartIdentifier match {
-          case Seq(db, fn) => FunctionIdentifier(fn, Some(db))
-          case Seq(fn) => FunctionIdentifier(fn, None)
-          case _ =>
-            throw new AnalysisException(s"Unsupported function name 
'${functionIdent.quoted}'")
-        }
-      } else {
-        throw new AnalysisException ("DESCRIBE FUNCTION is only supported in 
v1 catalog")
-      }
-      DescribeFunctionCommand(functionIdentifier, extended)
+      val (database, function) =
+        parseSessionCatalogFunctionIdentifier("DESCRIBE FUNCTION", catalog, 
functionIdent)
 
 Review comment:
   I'm not sure what are you proposing exactly. We could have something like 
that:
     
   ```
   case DescribeFunctionStatement(SessionCatalogAndFunction(catalog, 
functionIdent), extended) =>
   ...
   case DropFunctionStatement(SessionCatalogAndFunction(catalog, 
functionIdent), ifExists, isTemp) =>
   ...
   case CreateFunctionStatement(SessionCatalogAndFunction(catalog, 
functionIdent),
         className, resources, isTemp, ignoreIfExists, replace) =>
   ...
   ```
   where SessionCatalogAndFunction is an extractor that tests if 
isSessionCatalog, something like SessionCatalogAndTable do.
   In the case that !isSessionCatalog it implies that any of this cases match 
and the result is 
   `unresolved operator 'CreateFunctionStatement [testcat, ns1, ns2, fun]` for 
Create function 
   
   How could we catch this case generically and throw a generic exception like 
you propose?

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to