cloud-fan commented on code in PR #45146:
URL: https://github.com/apache/spark/pull/45146#discussion_r1503475140
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala:
##########
@@ -882,6 +882,30 @@ class FilterPushdownSuite extends PlanTest {
comparePlans(optimized, correctAnswer)
}
+ test("union part 2 electric razor idk") {
+ val nonNullableArray = StructField("a", ArrayType(IntegerType, false))
+ val bField = StructField("b", IntegerType)
+ val testRelationNonNull = LocalRelation(nonNullableArray, bField)
+ val testRelationNull = LocalRelation($"c".array(IntegerType), $"d".int)
+
+ val nonNullArrayRef = AttributeReference("a", ArrayType(IntegerType,
false))(
+ testRelationNonNull.output(0).exprId, List())
+
+
+ val originalQuery = Union(Seq(testRelationNonNull, testRelationNull))
+ .where(IsNotNull(nonNullArrayRef))
Review Comment:
ah, this reminds me of the rule `UpdateAttributeNullability` which does very
similar things for the same reason. It seems we need to update the nullability
of array/map elements and nested fields as well.
I think the dataframe col API is too powerful as it carries
`AttributeReference`, and can lead to undefined behavior. e.g.
`df1.union(df2).filter(df1("col").xxx)` will probably go wrong if `df1` and
`df2` have different column data types and during the predicate evaluation bad
things can happen as the actual value comes from Union will have a different
data type than `df1("col")`.
That said, I think we should not blindly look at the expr ID and ignore the
data type difference. We should only allow nullability different, and handle it
in `UpdateAttributeNullability`.
--
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]