@@ -22,7 +22,7 @@ import java.sql.{Date, Timestamp}
2222import scala .collection .immutable .HashSet
2323
2424import org .apache .spark .SparkFunSuite
25- import org .apache .spark .sql .RandomDataGenerator
25+ import org .apache .spark .sql .{ RandomDataGenerator , Row }
2626import org .apache .spark .sql .catalyst .{CatalystTypeConverters , InternalRow }
2727import org .apache .spark .sql .catalyst .analysis .TypeCheckResult
2828import org .apache .spark .sql .catalyst .encoders .ExamplePointUDT
@@ -91,6 +91,10 @@ class PredicateSuite extends SparkFunSuite with ExpressionEvalHelper {
9191 DataTypeTestUtils .propertyCheckSupported.foreach { dt =>
9292 checkConsistencyBetweenInterpretedAndCodegen(EqualTo , dt, dt)
9393 checkConsistencyBetweenInterpretedAndCodegen(EqualNullSafe , dt, dt)
94+
95+ val arrayType = ArrayType (dt)
96+ checkConsistencyBetweenInterpretedAndCodegen(EqualTo , arrayType, arrayType)
97+ checkConsistencyBetweenInterpretedAndCodegen(EqualNullSafe , arrayType, arrayType)
9498 }
9599 }
96100
@@ -496,11 +500,30 @@ class PredicateSuite extends SparkFunSuite with ExpressionEvalHelper {
496500 checkEvaluation(EqualTo (infinity, infinity), true )
497501 }
498502
499- test(" SPARK-32688: 0.0 and -0.0 should be considered equal" ) {
500- checkEvaluation(EqualTo (Literal (0.0 ), Literal (- 0.0 )), true )
501- checkEvaluation(EqualNullSafe (Literal (0.0 ), Literal (- 0.0 )), true )
502- checkEvaluation(EqualTo (Literal (0.0f ), Literal (- 0.0f )), true )
503- checkEvaluation(EqualNullSafe (Literal (0.0f ), Literal (- 0.0f )), true )
503+ private def testEquality (literals : Seq [Literal ]): Unit = {
504+ literals.foreach(left => {
505+ literals.foreach(right => {
506+ checkEvaluation(EqualTo (left, right), true )
507+ checkEvaluation(EqualNullSafe (left, right), true )
508+
509+ val leftArray = Literal .create(Array (left.value), ArrayType (left.dataType))
510+ val rightArray = Literal .create(Array (right.value), ArrayType (right.dataType))
511+ checkEvaluation(EqualTo (leftArray, rightArray), true )
512+ checkEvaluation(EqualNullSafe (leftArray, rightArray), true )
513+
514+ val leftStruct = Literal .create(
515+ Row (left.value), new StructType ().add(" a" , left.dataType))
516+ val rightStruct = Literal .create(
517+ Row (right.value), new StructType ().add(" a" , right.dataType))
518+ checkEvaluation(EqualTo (leftStruct, rightStruct), true )
519+ checkEvaluation(EqualNullSafe (leftStruct, rightStruct), true )
520+ })
521+ })
522+ }
523+
524+ test(" SPARK-32688: 0.0 and -0.0 should be equal" ) {
525+ testEquality(Seq (Literal (0.0 ), Literal (- 0.0 )))
526+ testEquality(Seq (Literal (0.0f ), Literal (- 0.0f )))
504527 }
505528
506529 test(" SPARK-22693: InSet should not use global variables" ) {
0 commit comments