Skip to content

fix: return EmptyExec for LIMIT 0 in physical planning - #30

Merged
askalt merged 1 commit into
release-52.3.0from
a.karpenko/fix-zero-limit-in-plc
Aug 26, 2026
Merged

askalt merged 1 commit into
release-52.3.0from
a.karpenko/fix-zero-limit-in-plc

Conversation

@karpenkoag

Copy link
Copy Markdown

Short-circuit physical planning when a limit requests zero rows by returning an EmptyExec with the input schema.

@github-actions github-actions Bot added the core label Aug 20, 2026
@karpenkoag
karpenkoag requested review from LLDay and askalt August 21, 2026 08:01
Comment thread datafusion/core/src/physical_planner.rs Outdated
Comment thread datafusion/core/src/physical_planner.rs Outdated
@LLDay

LLDay commented Aug 21, 2026

Copy link
Copy Markdown

Can fetch = 0 be passed to other LogicalPlan nodes? There is the fetch field in Sort and TableScan nodes.

@karpenkoag

Copy link
Copy Markdown
Author

Can fetch = 0 be passed to other LogicalPlan nodes? There is the fetch field in Sort and TableScan nodes.

@karpenkoag karpenkoag closed this Aug 24, 2026
@karpenkoag karpenkoag reopened this Aug 24, 2026
Short-circuit physical planning when a limit requests zero rows by
returning an EmptyExec with the input schema.
@karpenkoag
karpenkoag force-pushed the a.karpenko/fix-zero-limit-in-plc branch from 38b2f40 to 3722229 Compare August 24, 2026 16:38
@karpenkoag

Copy link
Copy Markdown
Author

Can fetch = 0 be passed to other LogicalPlan nodes? There is the fetch field in Sort and TableScan nodes.

At other points, fetch means the sum of limit and offset and is used for pushdown.

Previously, fetch =0 fell into the Sort node with "ORDER BY". But Sort and TableScan are deeper than LIMIT in logical plans, and now the case with LIMIT 0 will not reach them. I do not know how to create these nodes directly without a LIMIT.

@karpenkoag
karpenkoag requested a review from askalt August 26, 2026 07:05
@askalt
askalt merged commit ae72cac into release-52.3.0 Aug 26, 2026
48 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants