zhengruifeng commented on code in PR #48410:
URL: https://github.com/apache/spark/pull/48410#discussion_r1795330189


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/OptimizerSuite.scala:
##########
@@ -313,4 +313,23 @@ class OptimizerSuite extends PlanTest {
       assert(message1.contains("not a valid aggregate expression"))
     }
   }
+
+  test("SPARK-49924: Keep containsNull after replace ArrayCompact") {
+    val optimizer = new SimpleTestOptimizer() {
+      override def defaultBatches: Seq[Batch] =
+        Batch("test", fixedPoint,
+          ReplaceExpressions) :: Nil
+    }
+
+    val array1 = ArrayCompact(CreateArray(Literal(1) :: Literal.apply(null) :: 
Nil, false))
+    val plan1 = Project(Alias(array1, "arr")() :: Nil, 
OneRowRelation()).analyze
+    val optimized1 = optimizer.execute(plan1)
+     assert(plan1.schema === optimized1.schema)

Review Comment:
   before the fix, fails with
   ```
   [info]   StructType(StructField("arr", ArrayType(IntegerType, false), false, 
{})) did not equal StructType(StructField("arr", ArrayType(IntegerType, true), 
false, {})) (OptimizerSuite.scala:327)
   [info]   Analysis:
   [info]   StructType(0: StructField("arr", ArrayType(IntegerType, false), 
false, {}) -> StructField("arr", ArrayType(IntegerType, true), false, {}))
   
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to