Skip to content

Conversation

@zjregee
Copy link
Member

@zjregee zjregee commented Feb 5, 2025

Which issue does this PR close?

Closes #14337.

Rationale for this change

What changes are included in this PR?

Implement limit pushdown for MemoryExec, add unit test and modify outdated content in .slt test files.

Are these changes tested?

Yes.

Are there any user-facing changes?

None.

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) labels Feb 5, 2025
@zjregee zjregee force-pushed the impl-fetch-limit-for-memory-exec branch from 02efd60 to 13a0960 Compare February 5, 2025 09:43
@zjregee zjregee force-pushed the impl-fetch-limit-for-memory-exec branch from 13a0960 to 38edfcf Compare February 5, 2025 10:48
@github-actions github-actions bot added the core Core DataFusion crate label Feb 5, 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.

Thank you @zjregee ❤️

I have some small suggestions but we could do them as a follow on PR as well (they are not required to merge this PR in my opinion)

Thanks!

projection: Option<Vec<usize>>,
/// Index into the data
index: usize,
/// The remaining number of rows to return
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// The remaining number of rows to return
/// The remaining number of rows to return. If None, all rows are returned

Comment on lines +548 to +552
if self.fetch.is_none() {
return Poll::Ready(Some(Ok(batch)));
}

let fetch = self.fetch.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can write this more concisely and avoid the unwrap with something like

Suggested change
if self.fetch.is_none() {
return Poll::Ready(Some(Ok(batch)));
}
let fetch = self.fetch.unwrap();
let Some(&fetch) = self.fetch.as_ref() else {
return Poll::Ready(Some(Ok(batch)));
};

05)--------MemoryExec: partitions=1, partition_sizes=[1]
06)------GlobalLimitExec: skip=0, fetch=10
07)--------MemoryExec: partitions=1, partition_sizes=[1]
04)------MemoryExec: partitions=1, partition_sizes=[1], limit=1
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

@ozankabak
Copy link
Contributor

@alamb, this is subsumed by the unified source PR. Let's only merge this if we encounter an issue that will delay the other one, but let's hold off otherwise to avoid conflicts

@alamb alamb changed the title impl limit pushdown for MemoryExec Support Limit pushdown for MemoryExec Feb 5, 2025
@alamb
Copy link
Contributor

alamb commented Feb 5, 2025

@alamb, this is subsumed by the unified source PR. Let's only merge this if we encounter an issue that will delay the other one, but let's hold off otherwise to avoid conflicts

Sounds good

FWIW I think @ozankabak is talking about this PR:

@alamb
Copy link
Contributor

alamb commented Feb 6, 2025

Thank you for your patience @zjregee -- and I apologize that this feature was already underway when I field #14224

I am quite sorry if you feel your time was wasted.

@zjregee zjregee deleted the impl-fetch-limit-for-memory-exec branch February 7, 2025 03:29
@zjregee
Copy link
Member Author

zjregee commented Feb 7, 2025

It seems that the suggestions mentioned here are still feasible. I will use a follow on PR to add this.

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

Labels

core Core DataFusion crate physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement fetch limit for MemoryExec

3 participants