Skip to content

Fix: limit is missing after removing SPM #14569

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

Merged
merged 3 commits into from
Feb 10, 2025
Merged

Conversation

xudong963
Copy link
Member

Rationale for this change

It's clear that fetch will miss after removing SPM

What changes are included in this PR?

If SPM is with fetch, we won't remove it.

Are these changes tested?

Yes, ut

Are there any user-facing changes?

No

@github-actions github-actions bot added the core Core DataFusion crate label Feb 10, 2025
@github-actions github-actions bot added the optimizer Optimizer rules label Feb 10, 2025
];
let expected_optimized = [
"SortPreservingMergeExec: [non_nullable_col@1 ASC], fetch=100",
" SortExec: expr=[non_nullable_col@1 ASC], preserve_partitioning=[false]",
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wandering do we expect to optimize only sortExec with Topk(fetch) for the only one partition case?

Comment on lines +1961 to +1962
"LocalLimitExec: fetch=100",
" SortExec: expr=[non_nullable_col@1 ASC], preserve_partitioning=[false]",
Copy link
Member Author

@xudong963 xudong963 Feb 10, 2025

Choose a reason for hiding this comment

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

we should optimize such pattern to topk later

@xudong963 xudong963 mentioned this pull request Feb 10, 2025
26 tasks
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.

This makes sense to me -- thank you @xudong963

In general it seems like we have a class of bugs related to removing fetch -- maybe we should re-evaluate enforce_sorting for a more holistic fix if we find any more issues

@xudong963
Copy link
Member Author

xudong963 commented Feb 10, 2025

This makes sense to me -- thank you @xudong963

In general it seems like we have a class of bugs related to removing fetch -- maybe we should re-evaluate enforce_sorting for a more holistic fix if we find any more issues

yes, I also have the thought, enforce_sorting has so many condition branches, I'll do a refactor and add more tests for EnforceSorting when I have time.

Copy link
Contributor

@zhuqi-lucas zhuqi-lucas left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks @xudong963 !

@xudong963
Copy link
Member Author

Thanks all, let's go!

@xudong963 xudong963 merged commit dee0dc7 into apache:main Feb 10, 2025
24 checks passed
@xudong963 xudong963 deleted the fix_limit_smp branch February 10, 2025 14:38
xudong963 added a commit to polygon-io/arrow-datafusion that referenced this pull request Feb 12, 2025
* Fix: limit is missing after removing SPM

* fix test

* use limitexec
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.

3 participants