From e3293406119fcb7f438f5de1716057cf036e5a2a Mon Sep 17 00:00:00 2001 From: allisonwang-db Date: Mon, 10 Oct 2022 17:57:40 -0400 Subject: [PATCH] improve listFunctions --- .../spark/sql/catalyst/catalog/SessionCatalog.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala index cc2ba8ac7e4bb..bc01986afdb14 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala @@ -1784,11 +1784,11 @@ class SessionCatalog( } /** - * List all registered functions in a database with the given pattern. + * List all built-in and temporary functions with the given pattern. */ - private def listRegisteredFunctions(db: String, pattern: String): Seq[FunctionIdentifier] = { + private def listBuiltinAndTempFunctions(pattern: String): Seq[FunctionIdentifier] = { val functions = (functionRegistry.listFunction() ++ tableFunctionRegistry.listFunction()) - .filter(_.database.forall(_ == db)) + .filter(_.database.isEmpty) StringUtils.filterPattern(functions.map(_.unquotedString), pattern).map { f => // In functionRegistry, function names are stored as an unquoted format. Try(parser.parseFunctionIdentifier(f)) match { @@ -1817,7 +1817,7 @@ class SessionCatalog( requireDbExists(dbName) val dbFunctions = externalCatalog.listFunctions(dbName, pattern).map { f => FunctionIdentifier(f, Some(dbName)) } - val loadedFunctions = listRegisteredFunctions(db, pattern) + val loadedFunctions = listBuiltinAndTempFunctions(pattern) val functions = dbFunctions ++ loadedFunctions // The session catalog caches some persistent functions in the FunctionRegistry // so there can be duplicates.