Spark SQL UDF with varargs contains null and may return null
<p>Spark sql default provides a function greatest(Column... exprs) which will "Returns the greatest value of the list of values, skipping null values."</p>

<p>But recently we got a requirement that we needs a function my_greatest(Column... exprs) that</p>

<ul>
<li><p><strong>if exprs contains null, then return null</strong></p></li>
<li><p>otherwise return the greatest value of the list of values</p></li>
</ul>

<p>I checked the UDF of Spark SQL, it seems that I can not defined varargs contains null and can not return null.</p>

<p>Is there any way to implement this? thank you.</p>