Skip to content

feat(sql): support FETCH row limits - #82

Merged
osipovartem merged 1 commit into
embucket-sync-df55.0.0from
snowflake-fetch-clause
Sep 12, 2026
Merged

osipovartem merged 1 commit into
embucket-sync-df55.0.0from
snowflake-fetch-clause

Conversation

@osipovartem

Copy link
Copy Markdown
Collaborator

Summary

  • plan ANSI FETCH FIRST|NEXT <count> ROWS ONLY through DataFusion's existing limit expression path
  • combine OFFSET ... ROWS and FETCH into one logical Limit
  • support the standard omitted-quantity default of one row
  • apply FETCH consistently to SELECT and set-operation queries
  • retain explicit errors for unsupported PERCENT and WITH TIES options

Performance

FETCH produces the same logical and physical limit plans as LIMIT. ORDER BY ... FETCH remains eligible for DataFusion's bounded Top-K optimization. The implementation adds no per-row conversion or custom execution operator.

Validation

  • cargo +1.95.0 test -p datafusion-sql --test sql_integration (604 passed)
  • targeted FETCH planner tests (8 passed)
  • targeted SQLLogicTest record errors.slt:78 passed
  • cargo +1.95.0 clippy -p datafusion-sql --all-targets -- -D warnings
  • cargo +1.95.0 fmt --all -- --check
  • git diff --check

The complete fork-specific errors.slt currently has two unrelated pre-existing failures (CAST(c1 AS INT) and a constant-folded division-by-zero case); the changed FETCH record passes when selected directly.

@osipovartem
osipovartem merged commit 0055538 into embucket-sync-df55.0.0 Sep 12, 2026
17 of 19 checks passed
@osipovartem
osipovartem deleted the snowflake-fetch-clause branch September 12, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant