ulysses-you commented on a change in pull request #28840: URL: https://github.com/apache/spark/pull/28840#discussion_r442620715
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/LookupCatalog.scala ########## @@ -155,4 +155,37 @@ private[sql] trait LookupCatalog extends Logging { None } } + + /** + * Extract catalog and function identifier from a multi-part name with the current catalog if + * needed. + * + * Note that: function is only supported in v1 catalog. + */ + object CatalogAndFunctionIdentifier { + def unapply(nameParts: Seq[String]): Option[(CatalogPlugin, FunctionIdentifier)] = { + + if (nameParts.length == 1 && catalogManager.v1SessionCatalog.isTempFunction(nameParts.head)) { + return Some(currentCatalog, FunctionIdentifier(nameParts.head)) + } + + nameParts match { + case SessionCatalogAndIdentifier(catalog, ident) => + if (nameParts.length == 1) { + // If there is only one name part, it means the current catalog is the session catalog. + // Here we don't fill the default database, to keep the error message unchanged for + // v1 commands. + Some(catalog, FunctionIdentifier(nameParts.head, None)) + } else { + ident.namespace match { + case Array(db) => Some(catalog, FunctionIdentifier(ident.name, Some(db))) + case _ => + throw new AnalysisException(s"Unsupported function name '$ident'") + } + } + + case _ => throw new AnalysisException("Function command is only supported in v1 catalog") Review comment: `Function command` means `CREATE FUNCTION`, `DROP FUNCTION`, `DESC FUNCTION` ... It seems confused, is it better we list all the function command here ? ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org