File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions
core/src/test/scala/org/apache/spark/sql Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -511,7 +511,7 @@ abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes {
511511
512512 override def checkInputDataTypes (): TypeCheckResult = {
513513 // First check whether left and right have the same type, then check if the type is acceptable.
514- if (left.dataType != right.dataType) {
514+ if (! left.dataType.sameType( right.dataType) ) {
515515 TypeCheckResult .TypeCheckFailure (s " differing types in ' $sql' " +
516516 s " ( ${left.dataType.simpleString} and ${right.dataType.simpleString}). " )
517517 } else if (! inputType.acceptsType(left.dataType)) {
Original file line number Diff line number Diff line change @@ -1631,4 +1631,13 @@ class DataFrameSuite extends QueryTest with SharedSQLContext {
16311631 dates.except(widenTypedRows).collect()
16321632 dates.intersect(widenTypedRows).collect()
16331633 }
1634+
1635+ test(" SPARK-18070 binary operator should not consider nullability when comparing input types" ) {
1636+ val rows = Seq (Row (Seq (1 ), Seq (1 )))
1637+ val schema = new StructType ()
1638+ .add(" array1" , ArrayType (IntegerType ))
1639+ .add(" array2" , ArrayType (IntegerType , containsNull = false ))
1640+ val df = spark.createDataFrame(spark.sparkContext.makeRDD(rows), schema)
1641+ assert(df.filter($" array1" === $" array2" ).count() == 1 )
1642+ }
16341643}
You can’t perform that action at this time.
0 commit comments