apache/spark — pull request #482 by chenghao-intel (2014-04-22 08:54:50+00:00)
Title: [WIP][Spark-SQL] Optimize the Constant Folding for Expression

Currently, expression does not support the "constant null" well in constant folding.
e.g. Sum(a, null) actually always produces Literal(null, NumericType) in runtime.

I changed the nullable interface from
def nullable: Boolean => def nullable: Nullability
the Nullability has 3 concrete objects (neverNull, alwaysNull and possibleNull), which are very helpful hints in the constant folding in Optimizer.

For example:
```
explain select isnull(key+null) from src;
== Logical Plan ==
Project [HiveGenericUdf#isnull((key#30 + CAST(null, IntegerType))) AS c_0#28]
MetastoreRelation default, src, None

== Optimized Logical Plan ==
Project [true AS c_0#28]
MetastoreRelation default, src, None

== Physical Plan ==
Project [true AS c_0#28]
HiveTableScan [], (MetastoreRelation default, src, None), None
```