Skip to content

fix(sql): reject unsupported relation modifiers - #24758

Draft
geoffreyclaude wants to merge 2 commits into
apache:mainfrom
geoffreyclaude:codex/relation-modifier-rejection
Draft

geoffreyclaude wants to merge 2 commits into
apache:mainfrom
geoffreyclaude:codex/relation-modifier-rejection

Conversation

@geoffreyclaude

@geoffreyclaude geoffreyclaude commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

DataFusion's built-in SQL planner ignored some relation modifiers that sqlparser successfully parsed. For example, TABLESAMPLE could silently become an ordinary full table scan. This happened in vanilla DataFusion when no RelationPlanner was registered, and also after every registered planner declined the relation.

Queries should not succeed after silently changing their meaning. The built-in fallback should reject modifiers it cannot implement.

What changes are included in this PR?

When the built-in planner handles a relation, it now rejects unsupported modifiers on:

  • table references: hints, version qualifiers, partition selection, JSON paths, TABLESAMPLE, and index hints;
  • derived tables: TABLESAMPLE;
  • table functions: WITH ORDINALITY and SETTINGS.

Registered RelationPlanners still run before the built-in fallback. An extension can continue to handle any modifier it supports; the new errors apply only when no extension plans the relation.

The affected sqlparser structures are destructured exhaustively. If sqlparser adds another field, the compiler will require an explicit planning decision.

Are these changes tested?

Yes. The regression test covers every new rejection path both in vanilla DataFusion and after a pass-through extension planner. A separate example test confirms that an extension can still handle TABLESAMPLE.

Are there any user-facing changes?

Yes. Relation modifiers that the built-in planner previously accepted but ignored now return a clear unsupported-planning error. Queries without these modifiers are unchanged, as are queries whose modifiers are handled by an extension planner. There are no public API changes.

@github-actions github-actions Bot added sql SQL Planner core Core DataFusion crate labels Aug 28, 2026
@codecov-commenter

codecov-commenter commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.59%. Comparing base (4d3e79e) to head (23b1cc3).
⚠️ Report is 122 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24758      +/-   ##
==========================================
+ Coverage   81.48%   81.59%   +0.10%     
==========================================
  Files        1122     1123       +1     
  Lines      404248   410952    +6704     
  Branches   404248   410952    +6704     
==========================================
+ Hits       329390   335300    +5910     
- Misses      55547    55905     +358     
- Partials    19311    19747     +436     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale PR has not had any activity for some time label Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate sql SQL Planner Stale PR has not had any activity for some time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relation planning silently ignores unsupported table modifiers

2 participants