Skip to content

Commit 15d676a

Browse files
author
Gene Bordegaray
authored
Add Distribution::HashPartitioned to Distribution::KeyPartitioned API bridge (apache#23259)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link to an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#23236. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> `HashPartitioned` is historical naming for a key-partitioning requirement. This keeps the old variant as a deprecated compatibility bridge while moving DataFusion internals to `KeyPartitioned`. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Adds `KeyPartitioned`, deprecates `HashPartitioned`, and treats both equivalently during the transition to avoid breaking changes for downstream consumers. A blast radius report on this was done here apache#23241 ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> Yes, `Distribution::HashPartitioned` is deprecated and trainsitioned to `Distribution::KeyPartitioned`. <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent eaafba4 commit 15d676a

13 files changed

Lines changed: 153 additions & 73 deletions

File tree

‎datafusion/core/tests/physical_optimizer/ensure_requirements.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ fn test_idempotent_window_over_multi_partition() {
11131113
])
11141114
.unwrap();
11151115

1116-
let dist = Distribution::HashPartitioned(vec![Arc::new(Column::new("a", 0))]);
1116+
let dist = Distribution::KeyPartitioned(vec![Arc::new(Column::new("a", 0))]);
11171117
let window_like: Arc<dyn ExecutionPlan> =
11181118
Arc::new(MockReqExec::new(source, dist, Some(ord)));
11191119

‎datafusion/core/tests/physical_optimizer/projection_pushdown.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ fn test_output_req_after_projection() -> Result<()> {
724724
]
725725
.into(),
726726
)),
727-
Distribution::HashPartitioned(vec![
727+
Distribution::KeyPartitioned(vec![
728728
Arc::new(Column::new("a", 0)),
729729
Arc::new(Column::new("b", 1)),
730730
]),
@@ -746,7 +746,7 @@ fn test_output_req_after_projection() -> Result<()> {
746746
actual,
747747
@r"
748748
ProjectionExec: expr=[c@2 as c, a@0 as new_a, b@1 as b]
749-
OutputRequirementExec: order_by=[(b@1, asc), (c@2 + a@0, asc)], dist_by=HashPartitioned[[a@0, b@1]])
749+
OutputRequirementExec: order_by=[(b@1, asc), (c@2 + a@0, asc)], dist_by=KeyPartitioned[[a@0, b@1]])
750750
DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false
751751
"
752752
);
@@ -762,7 +762,7 @@ fn test_output_req_after_projection() -> Result<()> {
762762
assert_snapshot!(
763763
actual,
764764
@r"
765-
OutputRequirementExec: order_by=[(b@2, asc), (c@0 + new_a@1, asc)], dist_by=HashPartitioned[[new_a@1, b@2]])
765+
OutputRequirementExec: order_by=[(b@2, asc), (c@0 + new_a@1, asc)], dist_by=KeyPartitioned[[new_a@1, b@2]])
766766
DataSourceExec: file_groups={1 group: [[x]]}, projection=[c, a@0 as new_a, b], file_type=csv, has_header=false
767767
"
768768
);
@@ -797,7 +797,7 @@ fn test_output_req_after_projection() -> Result<()> {
797797
Arc::new(Column::new("new_a", 1)),
798798
Arc::new(Column::new("b", 2)),
799799
];
800-
if let Distribution::HashPartitioned(vec) = after_optimize
800+
if let Distribution::KeyPartitioned(vec) = after_optimize
801801
.downcast_ref::<OutputRequirementExec>()
802802
.unwrap()
803803
.required_input_distribution()[0]
@@ -809,7 +809,7 @@ fn test_output_req_after_projection() -> Result<()> {
809809
.all(|(actual, expected)| actual.eq(&expected))
810810
);
811811
} else {
812-
panic!("Expected HashPartitioned distribution!");
812+
panic!("Expected KeyPartitioned distribution!");
813813
};
814814

815815
Ok(())

0 commit comments

Comments
 (0)