-
Notifications
You must be signed in to change notification settings - Fork 1.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
Preserve constant values across union operations #13805
Preserve constant values across union operations #13805
Conversation
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 have just one suggestion, otherwise LGTM
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.
Thanks @gokselk and @berkaysynnada
I suggest we try to write an end to end sqllogictest for this query too.
I wonder if we should change enum PartitionValues {
Uniform(Option<ScalarValue>),
Heterogenous(Vec<Option<ScalarValue>>)
} with |
This reverts commit 3051cd4.
1a81628
to
f737c65
Compare
6cc8259
to
1917c0e
Compare
05)----Filter: aggregate_test_100.c1 = Utf8("a") | ||
06)------TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[aggregate_test_100.c1 = Utf8("a")] | ||
physical_plan | ||
01)CoalescePartitionsExec |
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.
This appears as SortPreservingMergeExec before these changes 👍🏻
I'm planning to merge this PR once the CI is all green |
Which issue does this PR close?
Closes #13804.
Rationale for this change
Currently, DataFusion doesn't preserve constant values across union operations even when both sides have the same constant value. This change enables better optimization by tracking and preserving constant values when they match.
What changes are included in this PR?
value: Option<ScalarValue>
field toConstExpr
ConstExpr
Are these changes tested?
Yes, added new test case
test_union_constant_value_preservation
that verifies constant value preservation across unions.Are there any user-facing changes?
No user-facing changes. This is an internal optimization improvement.