Skip to content

fix: fetch is missed during EnforceDistribution - #14207

Closed
xudong963 wants to merge 7 commits into
apache:mainfrom
xudong963:fix_enforce_distribution
Closed

fix: fetch is missed during EnforceDistribution#14207
xudong963 wants to merge 7 commits into
apache:mainfrom
xudong963:fix_enforce_distribution

Conversation

@xudong963

@xudong963 xudong963 commented Jan 20, 2025

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

The root of the bug is that if there is a SortPreservingMergeExec operator and it has the fetch, the method(remove_dist_changing_operators ) will remove it directly, and miss the fetch. So it's definitely a bug.

IIUC, SortPreservingMergeExec only will be added after EnforceSorting, so if we want to reproduce the bug, EnforceDistribution needs to run after EnforceSorting, the default physical optimizer has the order of rules: EnforceDistribution -> EnforceSorting, so it won't trigger the bug(fetch is missed), but if we run EnforceDistribution again after EnforceSorting, the bug will surface.

What the PR is doing is that it will remain the fetch of SortPreservingMergeExec and add it back if necessary, as the comments of the method said: If they are necessary, they will be added in subsequent stages.

What changes are included in this PR?

Avoid missing fetch during EnforceDistribution.

Are these changes tested?

YES

Are there any user-facing changes?

NO

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: applying multiple times EnforceDistribution generates invalid plan

3 participants