[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 <sarutak@oss.nttdata.com> Signed-off-by: HyukjinKwon <gurwls223@apache.org>
This commit is contained in:
parent
9d3d25bca4
commit
fa1cf5c207
|
@ -120,7 +120,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") ::
|
||||
|
@ -140,6 +141,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", "||")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue