spark-instrumented-optimizer/sql/catalyst/src/main
Dilip Biswal bb49661e19 [SPARK-25416][SQL] 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

Closes #22407 from dilipbiswal/SPARK-25416.

Authored-by: Dilip Biswal <dbiswal@us.ibm.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
2018-09-24 21:37:51 +08:00
..
antlr4/org/apache/spark/sql/catalyst/parser [SPARK-24966][SQL] Implement precedence rules for set operations. 2018-08-02 22:04:17 -07:00
java/org/apache/spark/sql Revert [SPARK-10399] [SPARK-23879] [SPARK-23762] [SPARK-25317] 2018-09-09 21:25:19 +08:00
scala/org/apache/spark/sql [SPARK-25416][SQL] ArrayPosition function may return incorrect result when right expression is implicitly down casted 2018-09-24 21:37:51 +08:00