beliefer commented on code in PR #37301:
URL: https://github.com/apache/spark/pull/37301#discussion_r930584912


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowFunctionsExec.scala:
##########
@@ -37,28 +38,27 @@ case class ShowFunctionsExec(
     systemScope: Boolean,
     pattern: Option[String]) extends V2CommandExec with LeafExecNode {
 
+  private def applyPattern(names: Seq[String]): Seq[String] = {
+    StringUtils.filterPattern(names.toSeq, pattern.getOrElse("*"))
+  }
+
   override protected def run(): Seq[InternalRow] = {
     val rows = new ArrayBuffer[InternalRow]()
     val systemFunctions = if (systemScope) {
-      // All built-in functions
-      (FunctionRegistry.functionSet ++ 
TableFunctionRegistry.functionSet).map(_.unquotedString) ++
-      // Hard code "<>", "!=", "between", "case", and "||"
-      // for now as there is no corresponding functions.
-      // "<>", "!=", "between", "case", and "||" is system functions,
-      // only show when systemScope=true
-      FunctionRegistry.builtinOperators.keys.toSeq
+      // All built-in functions, and operators such as "<>", "||"
+      val builtinFunctions = FunctionRegistry.functionSet ++ 
TableFunctionRegistry.functionSet
+      applyPattern(builtinFunctions.map(_.unquotedString).toSeq ++
+        FunctionRegistry.builtinOperators.keys.toSeq)
     } else Seq.empty
     val userFunctions = if (userScope) {
       // List all temporary functions in the session catalog
-      
session.sessionState.catalog.listTemporaryFunctions().map(_.unquotedString) ++
-      // List all functions registered in the given name space of the catalog
-      catalog.listFunctions(namespace.toArray).map(_.name()).toSeq
+      
applyPattern(session.sessionState.catalog.listTemporaryFunctions().map(_.unquotedString))
 ++
+        // List all functions registered in the given namespace of the catalog
+        
applyPattern(catalog.listFunctions(namespace.toArray).map(_.name())).map { 
funcName =>
+          (catalog.name() +: namespace :+ funcName).quoted
+        }
     } else Seq.empty
-    val allFunctions = StringUtils.filterPattern(
-      userFunctions ++ systemFunctions,
-      pattern.getOrElse("*")).distinct.sorted

Review Comment:
   In my minor opinion, the origin code only call `StringUtils.filterPattern` 
once,  it seems no need create a new method `applyPattern`.



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