Skip to content

Conversation

@kosiew
Copy link
Contributor

@kosiew kosiew commented Nov 14, 2025

Which issue does this PR close?

Rationale for this change

The FETCH NEXT clause was being parsed without triggering an error, resulting in the CLI executing queries containing unsupported SQL syntax. This could mislead users into believing the feature is supported and undermine SQL correctness guarantees. Adding explicit handling ensures unsupported syntax fails fast with a clear and consistent error message.

What changes are included in this PR?

  • Added explicit detection of the FETCH clause in SqlToRel and return a not_impl_err! when encountered.
  • Updated CLI integration tests to include a snapshot verifying that the CLI now returns an error when FETCH is used.
  • Added a SQL integration test confirming that the planner correctly rejects FETCH.
  • Updated user documentation to note that DataFusion does not currently support the SQL FETCH clause.

Are these changes tested?

Yes. The PR includes:

  • A new CLI integration test snapshot validating the error message.
  • A new SQL integration test (fetch_clause_is_not_supported) verifying planner behavior.

Are there any user-facing changes?

Yes. Queries using the SQL FETCH clause will now produce a clear error instead of executing unexpectedly. Documentation has been updated to reflect this behavior.

LLM-generated code disclosure

This pull request includes code that was generated with assistance from LLM.
All LLM-generated code in this PR has been manually reviewed and tested.

Add guard in SqlToRel::query_to_plan to reject queries
with FETCH clause, raising an explicit planner error.
Include a regression test for SELECT 1 FETCH NEXT 1 ROW
ONLY to ensure the error surfaces. Extend the CLI
integration suite to confirm the error is displayed
to users. Update SQL guide to note that FETCH is not
supported and users should use LIMIT instead.
Clone ORDER BY and LIMIT clauses only for SELECT set
expressions. Reuse originals for other branches to improve
efficiency and maintain consistency.
@github-actions github-actions bot added documentation Improvements or additions to documentation sql SQL Planner labels Nov 14, 2025
@kosiew kosiew marked this pull request as ready for review November 18, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL queries containing unsupported 'FETCH NEXT' keyword execute successfully (SQLStorm)

1 participant