Skip to content
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

Minor: use the minimum fetch #14221

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Minor: use the minimum fetch #14221

merged 1 commit into from
Jan 23, 2025

Conversation

xudong963
Copy link
Member

Which issue does this PR close?

Closes #14192 (comment)

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Jan 21, 2025
Copy link
Contributor

@berkaysynnada berkaysynnada left a comment

Choose a reason for hiding this comment

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

Thanks @xudong963. Can you also add a small unit test?

@xudong963
Copy link
Member Author

Thanks @xudong963. Can you also add a small unit test?

Thanks, I'll do it later

@xudong963
Copy link
Member Author

It's difficult for me to construct such ut, I didn't construct a test that will go to the condition

if !satisfy_parent {
// Make sure this `SortExec` satisfies parent requirements:
let sort_reqs = requirements.data.ordering_requirement.unwrap_or_default();
// It's possible current plan (`SortExec`) has a fetch value.
let fetch = requirements.data.fetch.or(sort_fetch);
requirements = requirements.children.swap_remove(0);
requirements = add_sort_above(requirements, sort_reqs, fetch);
.

Do you have any ideas? @berkaysynnada

@@ -107,6 +107,12 @@ fn pushdown_sorts_helper(
// Make sure this `SortExec` satisfies parent requirements:
let sort_reqs = requirements.data.ordering_requirement.unwrap_or_default();
// It's possible current plan (`SortExec`) has a fetch value.
// And if both of them have fetch values, we should use the minimum one.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's difficult for me to construct such ut, I didn't construct a test that will go to the condition

I don't think it is possible today to hit this code (as the requirements will contain the sort correctly)

Thus I think it would be fine to merge this as is in my opinion, or perhaps you could add a check that the requirement_fetch is <= the sort_fetch if present

@berkaysynnada
Copy link
Contributor

It's difficult for me to construct such ut, I didn't construct a test that will go to the condition

if !satisfy_parent {
// Make sure this `SortExec` satisfies parent requirements:
let sort_reqs = requirements.data.ordering_requirement.unwrap_or_default();
// It's possible current plan (`SortExec`) has a fetch value.
let fetch = requirements.data.fetch.or(sort_fetch);
requirements = requirements.children.swap_remove(0);
requirements = add_sort_above(requirements, sort_reqs, fetch);

.
Do you have any ideas? @berkaysynnada

It doesn't seem possible without explicitly setting it (and that would not have much meaning). Let's merge this once you've resolved the conflicts.

@github-actions github-actions bot added optimizer Optimizer rules and removed core Core DataFusion crate labels Jan 23, 2025
@xudong963
Copy link
Member Author

Thanks @alamb @berkaysynnada

@xudong963 xudong963 merged commit 0228bee into apache:main Jan 23, 2025
25 checks passed
@xudong963 xudong963 deleted the follow_14192 branch January 23, 2025 07:19
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.

3 participants