This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 22681a0 [SPARK-34697][SQL] Allow DESCRIBE FUNCTION and SHOW FUNCTIONS
explain about || (string concatenation operator)
22681a0 is described below
commit 22681a0449d9b7895c4d37e5368320a8f83de664
Author: Kousuke Saruta <[email protected]>
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 <[email protected]>
Signed-off-by: HyukjinKwon <[email protected]>
(cherry picked from commit fa1cf5c207352b4b485d6b0dbed5ce680a377204)
Signed-off-by: HyukjinKwon <[email protected]>
---
.../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 d55d696..8ab7d3d 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)
@@ -241,5 +245,5 @@ case class ShowFunctionsCommand(
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: [email protected]
For additional commands, e-mail: [email protected]