Commit eceb7fa
committed
physical_optimizer: preserve_file_partitions when num file groups < target_partitions (apache#21533)
## Rationale for this change
`datafusion.optimizer.preserve_file_partitions` would not actually
preserve the file partitions when the number of file groups is less than
the target_partitions. This is unexpected behavior. If a user wants to
preserve file partitions, it is because they want to avoid repartitions.
Before
```
ProjectionExec
AggregateExec: mode=FinalPartitioned, gby=[f_dkey, timestamp]
RepartitionExec: partitioning=Hash([f_dkey, timestamp], 4), input_partitions=3
AggregateExec: mode=Partial, gby=[f_dkey, timestamp]
DataSourceExec: file_groups=3, projection=[timestamp, value, f_dkey]
```
After
```
ProjectionExec
AggregateExec: mode=SinglePartitioned, gby=[f_dkey, timestamp]
DataSourceExec: file_groups=3, projection=[timestamp, value, f_dkey]
```
## What changes are included in this PR?
This change fixes that by updating 1 line in the `enforce_distribution`
optimizer rule.
## Are these changes tested?
Yes. In the `preserve_file_partitions` SLT.
## Are there any user-facing changes?
No.1 parent eae7bf4 commit eceb7fa
2 files changed
Lines changed: 61 additions & 1 deletion
File tree
- datafusion
- physical-optimizer/src
- sqllogictest/test_files
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1295 | 1295 | | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | | - | |
| 1298 | + | |
1299 | 1299 | | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
1300 | 1306 | | |
1301 | 1307 | | |
1302 | 1308 | | |
| |||
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
707 | 761 | | |
708 | 762 | | |
709 | 763 | | |
| |||
0 commit comments