-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-49924][SQL] Keep containsNull
after ArrayCompact
replacement
#48410
Conversation
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before the fix, fails with:
[info] StructType(StructField("map", MapType(IntegerType, IntegerType, false), false, {})) did not equal StructType(StructField("map", MapType(IntegerType, IntegerType, false), true, {})) (OptimizerSuite.scala:333)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should explicitly write out the expected schema. Most cases the schema of RuntimeReplaceable
and its replacement have the same schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
containsNull
of ArrayCompact
containsNull
of ArrayCompact
after replacement
93e3fb5
to
39e5616
Compare
containsNull
of ArrayCompact
after replacementcontainsNull
after ArrayCompact
replacement
5af26f9
to
758c58e
Compare
758c58e
to
1e75aa5
Compare
Merged to master. |
What changes were proposed in this pull request?
Fix
containsNull
ofArrayCompact
, by adding a new expressionKnownNotContainsNull
Why are the changes needed?
#47430 attempted to set
containsNull = false
forArrayCompact
for further optimization, but in an incomplete way:The
ArrayCompact
is a runtime replaceable expression, so will be replaced in optimizer, and cause thecontainsNull
be reverted, e.g.Rule
ReplaceExpressions
changedcontainsNull: false -> true
Does this PR introduce any user-facing change?
no
How was this patch tested?
added tests
Was this patch authored or co-authored using generative AI tooling?
no