This is an automated email from the ASF dual-hosted git repository. gurwls223 pushed a commit to branch branch-3.1 in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.1 by this push: new fe8ad5e [SPARK-34697][SQL] Allow DESCRIBE FUNCTION and SHOW FUNCTIONS explain about || (string concatenation operator) fe8ad5e is described below commit fe8ad5e12dd53327df46019784913685dbbc2298 Author: Kousuke Saruta <saru...@oss.nttdata.com> AuthorDate: Thu Mar 11 22:11:26 2021 +0900 [SPARK-34697][SQL] Allow DESCRIBE FUNCTION and SHOW FUNCTIONS explain about || (string concatenation operator) ### What changes were proposed in this pull request? This PR fixes the behavior of `SHOW FUNCTIONS` and `DESCRIBE FUNCTION` for the `||` operator. The result of `SHOW FUNCTIONS` doesn't contains `||` and `DESCRIBE FUNCTION ||` says `Function: || not found.` even though `||` is supported. ### Why are the changes needed? It's a bug. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Confirmed manually with the following commands. ``` spark-sql> DESCRIBE FUNCTION ||; Function: || Usage: expr1 || expr2 - Returns the concatenation of `expr1` and `expr2`. spark-sql> SHOW FUNCTIONS; ! != % ... | || ~ ``` Closes #31800 from sarutak/fix-describe-concat-pipe. Authored-by: Kousuke Saruta <saru...@oss.nttdata.com> Signed-off-by: HyukjinKwon <gurwls...@apache.org> (cherry picked from commit fa1cf5c207352b4b485d6b0dbed5ce680a377204) Signed-off-by: HyukjinKwon <gurwls...@apache.org> --- .../scala/org/apache/spark/sql/execution/command/functions.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala index 330a503..5c511ec 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala @@ -116,7 +116,8 @@ case class DescribeFunctionCommand( } override def run(sparkSession: SparkSession): Seq[Row] = { - // Hard code "<>", "!=", "between", and "case" for now as there is no corresponding functions. + // Hard code "<>", "!=", "between", "case", and "||" + // for now as there is no corresponding functions. functionName.funcName.toLowerCase(Locale.ROOT) match { case "<>" => Row(s"Function: $functionName") :: @@ -136,6 +137,9 @@ case class DescribeFunctionCommand( "[WHEN expr4 THEN expr5]* [ELSE expr6] END - " + "When `expr1` = `expr2`, returns `expr3`; " + "when `expr1` = `expr4`, return `expr5`; else return `expr6`.") :: Nil + case "||" => + Row("Function: ||") :: + Row("Usage: expr1 || expr2 - Returns the concatenation of `expr1` and `expr2`.") :: Nil case _ => try { val info = sparkSession.sessionState.catalog.lookupFunctionInfo(functionName) @@ -280,5 +284,5 @@ case class RefreshFunctionCommand( object FunctionsCommand { // operators that do not have corresponding functions. // They should be handled `DescribeFunctionCommand`, `ShowFunctionsCommand` - val virtualOperators = Seq("!=", "<>", "between", "case") + val virtualOperators = Seq("!=", "<>", "between", "case", "||") } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org