cloud-fan commented on code in PR #36977:
URL: https://github.com/apache/spark/pull/36977#discussion_r911782560


##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -440,8 +515,16 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
    * or a function.
    */
   override def functionExists(functionName: String): Boolean = {
-    val functionIdent = 
sparkSession.sessionState.sqlParser.parseFunctionIdentifier(functionName)
-    functionExists(functionIdent.database.orNull, functionIdent.funcName)
+    try {
+      val ident = 
sparkSession.sessionState.sqlParser.parseFunctionIdentifier(functionName)
+      functionExists(ident.database.orNull, ident.funcName)
+    } catch {
+      case e: org.apache.spark.sql.catalyst.parser.ParseException =>
+        val ident = 
sparkSession.sessionState.sqlParser.parseMultipartIdentifier(functionName)
+        val catalog =
+          
sparkSession.sessionState.catalogManager.catalog(ident(0)).asFunctionCatalog
+        catalog.functionExists(Identifier.of(Array(ident(1)), ident(2)))

Review Comment:
   This assumes the first name part is always the catalog, which is not the 
case. We may use the current catalog. I think we should rely on the analyzer 
and use `UnresolvedFunc`.



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