-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Calculate ordering equivalence for expressions (rather than just columns) #8281
Changes from 5 commits
7a1e030
b35d343
bb77516
b5f0ef8
8ee9f1e
3319c8d
13dcd6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,15 +357,19 @@ mod tests { | |
let physical_plan = | ||
sort_preserving_merge_exec(vec![sort_expr("a", &schema)], sort); | ||
|
||
let expected_input = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
let expected_input = [ | ||
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. Did these plans actually change? Or is this just whitespace changes? If it is just whitespace changes I would really appreciate breaking such changes out into their own PRs as they are much faster / easier to review and merge. 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. Just whitespace changes. Agree with your suggestion in general, we will try to improve our self discipline on that |
||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortExec: expr=[a@0 ASC NULLS LAST]", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortPreservingRepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8, sort_exprs=a@0 ASC NULLS LAST", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
} | ||
|
@@ -434,19 +438,20 @@ mod tests { | |
let physical_plan = | ||
sort_preserving_merge_exec(vec![sort_expr("a", &schema)], sort); | ||
|
||
let expected_input = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
let expected_input = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortExec: expr=[a@0 ASC NULLS LAST]", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortPreservingRepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8, sort_exprs=a@0 ASC NULLS LAST", | ||
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
|
||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
|
@@ -466,19 +471,23 @@ mod tests { | |
let physical_plan = | ||
sort_preserving_merge_exec(vec![sort_expr("a", &schema)], sort); | ||
|
||
let expected_input = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
let expected_input = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortExec: expr=[a@0 ASC NULLS LAST]", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" FilterExec: c@1 > 3", | ||
" SortPreservingRepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8, sort_exprs=a@0 ASC NULLS LAST", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
} | ||
|
@@ -499,21 +508,25 @@ mod tests { | |
let physical_plan = | ||
sort_preserving_merge_exec(vec![sort_expr("a", &schema)], sort); | ||
|
||
let expected_input = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
let expected_input = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortExec: expr=[a@0 ASC NULLS LAST]", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" FilterExec: c@1 > 3", | ||
" SortPreservingRepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8, sort_exprs=a@0 ASC NULLS LAST", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
} | ||
|
@@ -531,18 +544,22 @@ mod tests { | |
let physical_plan: Arc<dyn ExecutionPlan> = | ||
coalesce_partitions_exec(coalesce_batches_exec); | ||
|
||
let expected_input = ["CoalescePartitionsExec", | ||
let expected_input = [ | ||
"CoalescePartitionsExec", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["CoalescePartitionsExec", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"CoalescePartitionsExec", | ||
" CoalesceBatchesExec: target_batch_size=8192", | ||
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
} | ||
|
@@ -570,7 +587,7 @@ mod tests { | |
" FilterExec: c@1 > 3", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true" | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
|
@@ -603,16 +620,20 @@ mod tests { | |
sort, | ||
); | ||
|
||
let expected_input = ["SortPreservingMergeExec: [c@1 ASC]", | ||
let expected_input = [ | ||
"SortPreservingMergeExec: [c@1 ASC]", | ||
" SortExec: expr=[c@1 ASC]", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["SortPreservingMergeExec: [c@1 ASC]", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [c@1 ASC]", | ||
" SortExec: expr=[c@1 ASC]", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
} | ||
|
@@ -628,15 +649,19 @@ mod tests { | |
let physical_plan = | ||
sort_exec(vec![sort_expr("a", &schema)], coalesce_partitions, false); | ||
|
||
let expected_input = ["SortExec: expr=[a@0 ASC NULLS LAST]", | ||
let expected_input = [ | ||
"SortExec: expr=[a@0 ASC NULLS LAST]", | ||
" CoalescePartitionsExec", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortPreservingRepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8, sort_exprs=a@0 ASC NULLS LAST", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan); | ||
Ok(()) | ||
} | ||
|
@@ -766,15 +791,19 @@ mod tests { | |
let physical_plan = | ||
sort_preserving_merge_exec(vec![sort_expr("a", &schema)], sort); | ||
|
||
let expected_input = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
let expected_input = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortExec: expr=[a@0 ASC NULLS LAST]", | ||
" RepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
let expected_optimized = ["SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
let expected_optimized = [ | ||
"SortPreservingMergeExec: [a@0 ASC NULLS LAST]", | ||
" SortPreservingRepartitionExec: partitioning=Hash([c@1], 8), input_partitions=8, sort_exprs=a@0 ASC NULLS LAST", | ||
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], output_ordering=[a@0 ASC NULLS LAST], has_header=true"]; | ||
" CsvExec: file_groups={1 group: [[file_path]]}, projection=[a, c, d], output_ordering=[a@0 ASC NULLS LAST], has_header=true", | ||
]; | ||
assert_optimized!(expected_input, expected_optimized, physical_plan, true); | ||
Ok(()) | ||
} | ||
|
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.
why was this test changed?
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.
In the plan, there is a filter enforcing
c = 0
-- so having a sort onc
is a no-op logically. After recent improvements we are able to recognize things like that and remove sorts completely, so the test became moot in its old form.