cloud-fan commented on a change in pull request #27550: [SPARK-30799][SQL] "spark_catalog.t" should not be resolved to temp view URL: https://github.com/apache/spark/pull/27550#discussion_r379371879
########## File path: sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala ########## @@ -496,56 +510,94 @@ class ResolveSessionCatalog( case ShowTableProperties(r: ResolvedTable, propertyKey) if isSessionCatalog(r.catalog) => ShowTablePropertiesCommand(r.identifier.asTableIdentifier, propertyKey) - case DescribeFunctionStatement(CatalogAndIdentifier(catalog, ident), extended) => + case DescribeFunctionStatement(nameParts, extended) => val functionIdent = - parseSessionCatalogFunctionIdentifier("DESCRIBE FUNCTION", catalog, ident) + parseSessionCatalogFunctionIdentifier(nameParts, "DESCRIBE FUNCTION") DescribeFunctionCommand(functionIdent, extended) case ShowFunctionsStatement(userScope, systemScope, pattern, fun) => val (database, function) = fun match { - case Some(CatalogAndIdentifier(catalog, ident)) => + case Some(nameParts) => val FunctionIdentifier(fn, db) = - parseSessionCatalogFunctionIdentifier("SHOW FUNCTIONS", catalog, ident) + parseSessionCatalogFunctionIdentifier(nameParts, "SHOW FUNCTIONS") (db, Some(fn)) case None => (None, pattern) } ShowFunctionsCommand(database, function, userScope, systemScope) - case DropFunctionStatement(CatalogAndIdentifier(catalog, ident), ifExists, isTemp) => + case DropFunctionStatement(nameParts, ifExists, isTemp) => val FunctionIdentifier(function, database) = - parseSessionCatalogFunctionIdentifier("DROP FUNCTION", catalog, ident) + parseSessionCatalogFunctionIdentifier(nameParts, "DROP FUNCTION") DropFunctionCommand(database, function, ifExists, isTemp) - case CreateFunctionStatement(CatalogAndIdentifier(catalog, ident), + case CreateFunctionStatement(nameParts, className, resources, isTemp, ignoreIfExists, replace) => - val FunctionIdentifier(function, database) = - parseSessionCatalogFunctionIdentifier("CREATE FUNCTION", catalog, ident) - CreateFunctionCommand(database, function, className, resources, isTemp, ignoreIfExists, - replace) + if (isTemp) { + // temp func doesn't belong to any catalog and we shouldn't resolve catalog in the name. + val database = if (nameParts.length > 2) { + throw new AnalysisException(s"Unsupported function name '${nameParts.quoted}'") Review comment: This is consistent with https://github.com/apache/spark/pull/27550/files#diff-2e07be4d73605cb1941153441a0c0c14L536 ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org