SparkSQL function require type Decimal
<p>I designed the following function to work with arrays of any numeric type:</p>

<pre><code>def array_sum[T](item:Traversable[T])(implicit n:Numeric[T]) = item.sum
// Registers a function as a UDF so it can be used in SQL statements.
sqlContext.udf.register("array_sumD", array_sum(_:Seq[Float]))
</code></pre>

<p>But wanting to pass an array of type float me the following error: </p>

<pre><code>// Now we can use our function directly in SparkSQL.
sqlContext.sql("SELECT array_sumD(array(5.0,1.0,2.0)) as array_sum").show
</code></pre>

<p>Error: </p>

<pre><code> cannot resolve 'UDF(array(5.0,1.0,2.0))' due to data type mismatch: argument 1 requires array&lt;double&gt; type, however, 'array(5.0,1.0,2.0)' is of array&lt;decimal(2,1)&gt; type;
</code></pre>