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


##########
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:
   We can't apply only once after this PR. The pattern will be applied to 
function names only, not qualified names. So I have to apply the pattern 
separately for persistent functions before generating qualified names.



##########
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:
   We can't apply only once after this PR. The pattern should be applied to 
function names only, not qualified names. So I have to apply the pattern 
separately for persistent functions before generating qualified names.



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