-
Notifications
You must be signed in to change notification settings - Fork 2k
physical_optimizer: preserve_file_partitions when num file groups < target_partitions #21533
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
Open
jayshrivastava
wants to merge
2
commits into
apache:main
Choose a base branch
from
jayshrivastava:js/remove-repartition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−1
Open
Changes from all commits
Commits
Show all changes
2 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 |
|---|---|---|
|
|
@@ -698,6 +698,60 @@ A dev 772.4 | |
| B prod 614.4 | ||
| C prod 2017.6 | ||
|
|
||
| ########## | ||
| # TEST 13: Partitioned Join where Number of File Groups is less than target_partitions | ||
| # With preserve_file_partitions enabled, we should still avoid repartitioning | ||
| ########## | ||
|
|
||
| statement ok | ||
| set datafusion.execution.target_partitions = 4; | ||
|
|
||
| statement ok | ||
| set datafusion.optimizer.preserve_file_partitions = 1; | ||
|
|
||
| query TT | ||
| EXPLAIN SELECT f_dkey, timestamp, | ||
| COUNT(*), AVG(value) | ||
| FROM fact_table | ||
| GROUP BY f_dkey, timestamp; | ||
| ---- | ||
| logical_plan | ||
| 01)Projection: fact_table.f_dkey, fact_table.timestamp, count(Int64(1)) AS count(*), avg(fact_table.value) | ||
| 02)--Aggregate: groupBy=[[fact_table.f_dkey, fact_table.timestamp]], aggr=[[count(Int64(1)), avg(fact_table.value)]] | ||
| 03)----TableScan: fact_table projection=[timestamp, value, f_dkey] | ||
| physical_plan | ||
| 01)ProjectionExec: expr=[f_dkey@0 as f_dkey, timestamp@1 as timestamp, count(Int64(1))@2 as count(*), avg(fact_table.value)@3 as avg(fact_table.value)] | ||
| 02)--AggregateExec: mode=SinglePartitioned, gby=[f_dkey@2 as f_dkey, timestamp@0 as timestamp], aggr=[count(Int64(1)), avg(fact_table.value)] | ||
| 03)----DataSourceExec: file_groups={3 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/preserve_file_partitioning/fact/f_dkey=A/data.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/preserve_file_partitioning/fact/f_dkey=B/data.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/preserve_file_partitioning/fact/f_dkey=C/data.parquet]]}, projection=[timestamp, value, f_dkey], file_type=parquet | ||
|
Contributor
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. Nice. We want to keep these 3 partitions as-is. We do not want to repartition it to the number of target_partitions |
||
|
|
||
| query TPIR rowsort | ||
| SELECT f_dkey, timestamp, | ||
| COUNT(*), AVG(value) | ||
| FROM fact_table | ||
| GROUP BY f_dkey, timestamp; | ||
| ---- | ||
| A 2023-01-01T09:00:00 1 95.5 | ||
| A 2023-01-01T09:00:10 1 102.3 | ||
| A 2023-01-01T09:00:20 1 98.7 | ||
| A 2023-01-01T09:12:20 1 105.1 | ||
| A 2023-01-01T09:12:30 1 100 | ||
| A 2023-01-01T09:12:40 1 150 | ||
| A 2023-01-01T09:12:50 1 120.8 | ||
| B 2023-01-01T09:00:00 1 75.2 | ||
| B 2023-01-01T09:00:10 1 82.4 | ||
| B 2023-01-01T09:00:20 1 78.9 | ||
| B 2023-01-01T09:00:30 1 85.6 | ||
| B 2023-01-01T09:12:30 1 80 | ||
| B 2023-01-01T09:12:40 1 120 | ||
| B 2023-01-01T09:12:50 1 92.3 | ||
| C 2023-01-01T09:00:00 1 300.5 | ||
| C 2023-01-01T09:00:10 1 285.7 | ||
| C 2023-01-01T09:00:20 1 310.2 | ||
| C 2023-01-01T09:00:30 1 295.8 | ||
| C 2023-01-01T09:00:40 1 300 | ||
| C 2023-01-01T09:12:40 1 250 | ||
| C 2023-01-01T09:12:50 1 275.4 | ||
|
|
||
| ########## | ||
| # CLEANUP | ||
| ########## | ||
|
|
||
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.
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 condition is needed to preserve file partition even if current partition < target_partitions