cloud-fan commented on code in PR #48410:
URL: https://github.com/apache/spark/pull/48410#discussion_r1796273894
##########
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)
+
+ val struct = CreateStruct(Literal(1) :: Literal(2) :: Nil)
+ val array2 = ArrayCompact(CreateArray(struct :: Literal.apply(null) ::
Nil, false))
+ val plan2 = Project(Alias(MapFromEntries(array2), "map")() :: Nil,
OneRowRelation()).analyze
+ val optimized2 = optimizer.execute(plan2)
+ assert(plan2.schema === optimized2.schema)
Review Comment:
I think we should explicitly write out the expected schema. Most cases the
schema of `RuntimeReplaceable` and its replacement have the same schema.
--
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]