Skip to content

Conversation

@gene-bordegaray
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Eliminates dead code that was not used in the enforce distribution rule.

In the branch where a parent requires hash repartitioning, there was a condition that would "add" a round robin if hash was not necessary (already hashed correctly) and the add round-robin flag was marked as true. This condition would never evaluate to true because anytime a parent requires hash repartitioning, we cannot round-robin because it would break the hash partitioning.

What changes are included in this PR?

A condition is deleted. No tests or plans were changed since this was dead code.

Are these changes tested?

Yes, all tests (unit and sqllogictests) still pass.

There is no new tests to add.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the optimizer Optimizer rules label Dec 6, 2025
@gene-bordegaray gene-bordegaray marked this pull request as ready for review December 6, 2025 14:07
@gene-bordegaray gene-bordegaray changed the title Eliminate dead round-robin insertion in enforce distribution bug: Eliminate dead round-robin insertion in enforce distribution Dec 6, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me -- thanks @gene-bordegaray

child = add_merge_on_top(child);
}
Distribution::HashPartitioned(exprs) => {
// See https://github.com/apache/datafusion/issues/18341#issuecomment-3503238325 for background
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this comment too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I will update this documentation to be accurate. I think it is still useful for people who want to dive into this part of the codebase

@alamb alamb added this pull request to the merge queue Dec 11, 2025
Merged via the queue into apache:main with commit a3b3eb5 Dec 11, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete Unneecessary Round-Robin Condition in Repartitioning

2 participants