forked from apache/datafusion
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: workaround exponential planning time bug in DF fork #55
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
Closed
alamb
wants to merge
3
commits into
influxdata:iox-13280/upgrade-df-ver45
from
alamb:iox-13280/upgrade-df-ver45
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2148,17 +2148,38 @@ fn calculate_union_binary( | |
}) | ||
.collect::<Vec<_>>(); | ||
|
||
// TEMP HACK WORKAROUND | ||
// Revert code from https://github.com/apache/datafusion/pull/12562 | ||
// Context: https://github.com/apache/datafusion/issues/13748 | ||
// Context: https://github.com/influxdata/influxdb_iox/issues/13038 | ||
|
||
// Next, calculate valid orderings for the union by searching for prefixes | ||
// in both sides. | ||
let mut orderings = UnionEquivalentOrderingBuilder::new(); | ||
orderings.add_satisfied_orderings(lhs.normalized_oeq_class(), lhs.constants(), &rhs); | ||
orderings.add_satisfied_orderings(rhs.normalized_oeq_class(), rhs.constants(), &lhs); | ||
let orderings = orderings.build(); | ||
|
||
let mut eq_properties = | ||
EquivalenceProperties::new(lhs.schema).with_constants(constants); | ||
|
||
let mut orderings = vec![]; | ||
for mut ordering in lhs.normalized_oeq_class().into_iter() { | ||
// Progressively shorten the ordering to search for a satisfied prefix: | ||
while !rhs.ordering_satisfy(&ordering) { | ||
ordering.pop(); | ||
} | ||
// There is a non-trivial satisfied prefix, add it as a valid ordering: | ||
if !ordering.is_empty() { | ||
orderings.push(ordering); | ||
} | ||
} | ||
for mut ordering in rhs.normalized_oeq_class().into_iter() { | ||
// Progressively shorten the ordering to search for a satisfied prefix: | ||
while !lhs.ordering_satisfy(&ordering) { | ||
ordering.pop(); | ||
} | ||
// There is a non-trivial satisfied prefix, add it as a valid ordering: | ||
if !ordering.is_empty() { | ||
orderings.push(ordering); | ||
} | ||
} | ||
let mut eq_properties = EquivalenceProperties::new(lhs.schema); | ||
eq_properties.constants = constants; | ||
eq_properties.add_new_orderings(orderings); | ||
|
||
Ok(eq_properties) | ||
} | ||
|
||
|
@@ -2204,6 +2225,7 @@ struct UnionEquivalentOrderingBuilder { | |
orderings: Vec<LexOrdering>, | ||
} | ||
|
||
#[expect(unused)] | ||
impl UnionEquivalentOrderingBuilder { | ||
fn new() -> Self { | ||
Self { orderings: vec![] } | ||
|
@@ -3552,134 +3574,6 @@ mod tests { | |
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_fill_gaps() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are tests of the reverted behavior so I removed them in this commit |
||
let schema = create_test_schema().unwrap(); | ||
UnionEquivalenceTest::new(&schema) | ||
.with_child_sort_and_const_exprs( | ||
// First child orderings: [a ASC, c ASC], const [b] | ||
vec![vec!["a", "c"]], | ||
vec!["b"], | ||
&schema, | ||
) | ||
.with_child_sort_and_const_exprs( | ||
// Second child orderings: [b ASC, c ASC], const [a] | ||
vec![vec!["b", "c"]], | ||
vec!["a"], | ||
&schema, | ||
) | ||
.with_expected_sort_and_const_exprs( | ||
// Union orderings: [ | ||
// [a ASC, b ASC, c ASC], | ||
// [b ASC, a ASC, c ASC] | ||
// ], const [] | ||
vec![vec!["a", "b", "c"], vec!["b", "a", "c"]], | ||
vec![], | ||
) | ||
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_no_fill_gaps() { | ||
let schema = create_test_schema().unwrap(); | ||
UnionEquivalenceTest::new(&schema) | ||
.with_child_sort_and_const_exprs( | ||
// First child orderings: [a ASC, c ASC], const [d] // some other constant | ||
vec![vec!["a", "c"]], | ||
vec!["d"], | ||
&schema, | ||
) | ||
.with_child_sort_and_const_exprs( | ||
// Second child orderings: [b ASC, c ASC], const [a] | ||
vec![vec!["b", "c"]], | ||
vec!["a"], | ||
&schema, | ||
) | ||
.with_expected_sort_and_const_exprs( | ||
// Union orderings: [[a]] (only a is constant) | ||
vec![vec!["a"]], | ||
vec![], | ||
) | ||
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_fill_some_gaps() { | ||
let schema = create_test_schema().unwrap(); | ||
UnionEquivalenceTest::new(&schema) | ||
.with_child_sort_and_const_exprs( | ||
// First child orderings: [c ASC], const [a, b] // some other constant | ||
vec![vec!["c"]], | ||
vec!["a", "b"], | ||
&schema, | ||
) | ||
.with_child_sort_and_const_exprs( | ||
// Second child orderings: [a DESC, b], const [] | ||
vec![vec!["a DESC", "b"]], | ||
vec![], | ||
&schema, | ||
) | ||
.with_expected_sort_and_const_exprs( | ||
// Union orderings: [[a, b]] (can fill in the a/b with constants) | ||
vec![vec!["a DESC", "b"]], | ||
vec![], | ||
) | ||
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_fill_gaps_non_symmetric() { | ||
let schema = create_test_schema().unwrap(); | ||
UnionEquivalenceTest::new(&schema) | ||
.with_child_sort_and_const_exprs( | ||
// First child orderings: [a ASC, c ASC], const [b] | ||
vec![vec!["a", "c"]], | ||
vec!["b"], | ||
&schema, | ||
) | ||
.with_child_sort_and_const_exprs( | ||
// Second child orderings: [b ASC, c ASC], const [a] | ||
vec![vec!["b DESC", "c"]], | ||
vec!["a"], | ||
&schema, | ||
) | ||
.with_expected_sort_and_const_exprs( | ||
// Union orderings: [ | ||
// [a ASC, b ASC, c ASC], | ||
// [b ASC, a ASC, c ASC] | ||
// ], const [] | ||
vec![vec!["a", "b DESC", "c"], vec!["b DESC", "a", "c"]], | ||
vec![], | ||
) | ||
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_gap_fill_symmetric() { | ||
let schema = create_test_schema().unwrap(); | ||
UnionEquivalenceTest::new(&schema) | ||
.with_child_sort_and_const_exprs( | ||
// First child: [a ASC, b ASC, d ASC], const [c] | ||
vec![vec!["a", "b", "d"]], | ||
vec!["c"], | ||
&schema, | ||
) | ||
.with_child_sort_and_const_exprs( | ||
// Second child: [a ASC, c ASC, d ASC], const [b] | ||
vec![vec!["a", "c", "d"]], | ||
vec!["b"], | ||
&schema, | ||
) | ||
.with_expected_sort_and_const_exprs( | ||
// Union orderings: | ||
// [a, b, c, d] | ||
// [a, c, b, d] | ||
vec![vec!["a", "c", "b", "d"], vec!["a", "b", "c", "d"]], | ||
vec![], | ||
) | ||
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_gap_fill_and_common() { | ||
let schema = create_test_schema().unwrap(); | ||
|
@@ -3705,34 +3599,6 @@ mod tests { | |
.run() | ||
} | ||
|
||
#[test] | ||
fn test_union_equivalence_properties_constants_middle_desc() { | ||
let schema = create_test_schema().unwrap(); | ||
UnionEquivalenceTest::new(&schema) | ||
.with_child_sort_and_const_exprs( | ||
// NB `b DESC` in the first child | ||
// | ||
// First child: [a ASC, b DESC, d ASC], const [c] | ||
vec![vec!["a", "b DESC", "d"]], | ||
vec!["c"], | ||
&schema, | ||
) | ||
.with_child_sort_and_const_exprs( | ||
// Second child: [a ASC, c ASC, d ASC], const [b] | ||
vec![vec!["a", "c", "d"]], | ||
vec!["b"], | ||
&schema, | ||
) | ||
.with_expected_sort_and_const_exprs( | ||
// Union orderings: | ||
// [a, b, d] (c constant) | ||
// [a, c, d] (b constant) | ||
vec![vec!["a", "c", "b DESC", "d"], vec!["a", "b DESC", "c", "d"]], | ||
vec![], | ||
) | ||
.run() | ||
} | ||
|
||
// TODO tests with multiple constants | ||
|
||
#[derive(Debug)] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.