-
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
fix: Fix eq properties regression from #10434 #11363
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.
LGTM!. Thanks @suremarc for this PR. This is really nice.
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 @suremarc and @mustafasrepo
// Add equal expressions to the state | ||
self.eq_group.add_equal_conditions(left, right); | ||
|
||
// Discover any new orderings | ||
self.discover_new_orderings(left)?; |
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.
❤️
col(name, &schema).map(|col| PhysicalSortExpr { | ||
expr: col, | ||
options: SortOptions::default(), | ||
// Construct the equivalence properties in different orders |
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 also verified test coverage by running these tests without the code changes and verified they do in fact fail ✅
thread 'equivalence::properties::tests::test_eliminate_redundant_monotonic_sorts' panicked at datafusion/physical-expr/src/equivalence/properties.rs:2493:17:
assertion `left == right` failed: failed test '(a, b, c) -> (c)'
left: false
right: true
stack backtrace:
0: rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:364:5
4: datafusion_physical_expr::equivalence::properties::tests::test_eliminate_redundant_monotonic_sorts
at ./src/equivalence/properties.rs:2493:17
5: datafusion_physical_expr::equivalence::properties::tests::test_eliminate_redundant_monotonic_sorts::{{closure}}
at ./src/equivalence/properties.rs:2382:54
6: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: test failed, to rerun pass `--lib`
error: 1 target failed:
`--lib`
* discover new orderings when constants are added * more comments * reduce nesting + describe argument * lint?
* discover new orderings when constants are added * more comments * reduce nesting + describe argument * lint?
* discover new orderings when constants are added * more comments * reduce nesting + describe argument * lint?
* discover new orderings when constants are added * more comments * reduce nesting + describe argument * lint?
Which issue does this PR close?
Closes #11362.
Rationale for this change
This PR fixes a regression in #10434. The previous PR implements "discovery" of new orderings when equal conditions are added. However, this discovery process is not carried out when constants are added.
As a result, adding equality conditions tends to leave the properties in a normalized state, but adding constants does not leave the properties in a normalized state. Thus the order in which one constructs the properties matters.
Since the existing test for this feature applied equal conditions after adding constants, this path dependence was not caught.
What changes are included in this PR?
We extract out the "discovery" logic into a helper method, and we ensure it is called not only when adding equal conditions, but also when adding constants.
Are these changes tested?
Yes; we modify the test to construct the equivalence properties in different orders.
Are there any user-facing changes?
No, aside from improved physical plans in some cases