Skip to content

Commit 1270e71

Browse files
viiryaHyukjinKwon
authored andcommitted
[SPARK-22086][DOCS] Add expression description for CASE WHEN
## What changes were proposed in this pull request? In SQL conditional expressions, only CASE WHEN lacks for expression description. This patch fills the gap. ## How was this patch tested? Only documentation change. Author: Liang-Chi Hsieh <[email protected]> Closes #19304 from viirya/casewhen-doc.
1 parent 1d1a09b commit 1270e71

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,22 @@ abstract class CaseWhenBase(
223223
*/
224224
// scalastyle:off line.size.limit
225225
@ExpressionDescription(
226-
usage = "CASE WHEN expr1 THEN expr2 [WHEN expr3 THEN expr4]* [ELSE expr5] END - When `expr1` = true, returns `expr2`; when `expr3` = true, return `expr4`; else return `expr5`.")
226+
usage = "CASE WHEN expr1 THEN expr2 [WHEN expr3 THEN expr4]* [ELSE expr5] END - When `expr1` = true, returns `expr2`; else when `expr3` = true, returns `expr4`; else returns `expr5`.",
227+
arguments = """
228+
Arguments:
229+
* expr1, expr3 - the branch condition expressions should all be boolean type.
230+
* expr2, expr4, expr5 - the branch value expressions and else value expression should all be
231+
same type or coercible to a common type.
232+
""",
233+
examples = """
234+
Examples:
235+
> SELECT CASE WHEN 1 > 0 THEN 1 WHEN 2 > 0 THEN 2.0 ELSE 1.2 END;
236+
1
237+
> SELECT CASE WHEN 1 < 0 THEN 1 WHEN 2 > 0 THEN 2.0 ELSE 1.2 END;
238+
2
239+
> SELECT CASE WHEN 1 < 0 THEN 1 WHEN 2 < 0 THEN 2.0 ELSE null END;
240+
NULL
241+
""")
227242
// scalastyle:on line.size.limit
228243
case class CaseWhen(
229244
val branches: Seq[(Expression, Expression)],

0 commit comments

Comments
 (0)