apache/spark — pull request #2768 by willb (2014-10-11 12:49:42+00:00)
Title: SPARK-2863: [SQL] Add facilities for function-argument coercion

This commit adds the `SignedFunction` trait and modifies the `Sqrt` expression
class to use it for coercing its argument to `DoubleType`.

`SignedFunction` represents a fixed-arity function whose arguments should be
casted to particular types. Expression classes extending SignedFunction
must provide `formalTypes`, a List of expected types for formal parameters,
`actualParams`, a list of Expressions corresponding to actual parameters,
and create, which creates an instance of that expression class from a list
of expressions corresponding to actuals. The type parameter for
SignedFunction should be the expression class extending it.

See the Sqrt class for a concrete example.

This trait (or one or several abstract classes extending this trait) could
be exposed to code outside `sql` in the future.