Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19752#discussion_r153079959
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
 ---
    @@ -141,14 +141,34 @@ case class If(predicate: Expression, trueValue: 
Expression, falseValue: Expressi
     }
     
     /**
    - * Abstract parent class for common logic in CaseWhen and CaseWhenCodegen.
    + * Case statements of the form "CASE WHEN a THEN b [WHEN c THEN d]* [ELSE 
e] END".
    + * When a = true, returns b; when c = true, returns d; else returns e.
      *
      * @param branches seq of (branch condition, branch value)
      * @param elseValue optional value for the else branch
      */
    -abstract class CaseWhenBase(
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  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`.",
    +  arguments = """
    +    Arguments:
    +      * expr1, expr3 - the branch condition expressions should all be 
boolean type.
    +      * expr2, expr4, expr5 - the branch value expressions and else value 
expression should all be
    +          same type or coercible to a common type.
    +  """,
    +  examples = """
    +    Examples:
    +      > SELECT CASE WHEN 1 > 0 THEN 1 WHEN 2 > 0 THEN 2.0 ELSE 1.2 END;
    +       1
    +      > SELECT CASE WHEN 1 < 0 THEN 1 WHEN 2 > 0 THEN 2.0 ELSE 1.2 END;
    +       2
    +      > SELECT CASE WHEN 1 < 0 THEN 1 WHEN 2 < 0 THEN 2.0 ELSE null END;
    --- End diff --
    
    Could you double check Hive returns NULL in the following case?
    > SELECT CASE WHEN 1 < 0 THEN 1 WHEN 2 < 0 THEN 2.0 END;



---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to