[SPARK-2053][SQL] Add Catalyst expressions for CASE WHEN.

JIRA ticket: https://issues.apache.org/jira/browse/SPARK-2053

This PR adds support for two types of CASE statements present in Hive. The first type is of the form `CASE WHEN a THEN b [WHEN c THEN d]* [ELSE e] END`, with the semantics like a chain of if statements, which is implemented in `CaseWhen`. The second type is of the form `CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END`, with the semantics like a switch statement on key `a`, which is implemented in `CaseKeyWhen`. 

[This link](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-ConditionalFunctions) contains more detailed descriptions on their semantics.

Notes / Open issues:

* Please help look at the two new case classes and check if any implicit contracts / invariants are broken in the implementations. I am not very familiar with them and I currently find them tricky to spot.
* We should decide whether or not a non-boolean condition is allowed in a branch of `CaseWhen`. Hive throws a `SemanticException` for this situation and I think it'd be good to mimic it -- the question is where in the whole Spark SQL pipeline should we signal an exception for such a query.
I.e. using Jekyll to build the docs & verify results?


On Thu, Jun 12, 2014 at 1:33 PM, Michael Armbrust <notifications@github.com>
wrote:

> In
> sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala:
>
> > @@ -202,3 +203,139 @@ case class If(predicate: Expression, trueValue: Expression, falseValue: Expressi
> >
> >    override def toString = s"if ($predicate) $trueValue else $falseValue"
> >  }
> > +
> > +// scalastyle:off
>
> Yeah, I didn't realize you turned it right back on. I'm OK now (really we
> should fix the style checker as long URLs are ok).
>
> Can we check that the turning the style off doesn't break the scala doc?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/apache/spark/pull/1055/files#r13724617>.
>