GitHub user dilipbiswal opened a pull request: https://github.com/apache/spark/pull/22407
[SPARK-25415] ArrayPosition function may return incorrect result when right expression is implicitly down casted ## What changes were proposed in this pull request? In ArrayPosition, we currently cast the right hand side expression to match the element type of the left hand side Array. This may result in down casting and may return wrong result or questionable result. Example : ```SQL spark-sql> select array_position(array(1), 1.34); 1 ``` ```SQL spark-sql> select array_position(array(1), 'foo'); null ``` We should safely coerce both left and right hand side expressions. ## How was this patch tested? Added tests in DataFrameFunctionsSuite You can merge this pull request into a Git repository by running: $ git pull https://github.com/dilipbiswal/spark SPARK-25416 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/22407.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #22407 ---- commit 629ec84389d2decd876be085b8df915f8e6c74cf Author: Dilip Biswal <dbiswal@...> Date: 2018-09-12T07:44:23Z [SPARK-25415] ArrayPosition function may return incorrect result when right expression is implicitly down casted. ---- --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org