GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DuckDB: support LIMIT 10% and TABLESAMPLE without a method by guizmaii · Pull Request #2802 · JSQLParser/JSqlParser

Conversation

@guizmaii

@guizmaii guizmaii commented Oct 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

For DuckDB's percentage limits (docs) and TABLESAMPLE forms (docs).

Input Before After
LIMIT 10%, LIMIT 40 PERCENT, LIMIT 50% OFFSET 2 error Limit with getPercentUnit() % / PERCENT
TABLESAMPLE 10%, TABLESAMPLE 10 ROWS, TABLESAMPLE reservoir(10 ROWS) REPEATABLE (1) error SampleClause, method optional as for USING SAMPLE
FROM range(10) r USING SAMPLE 10% sample silently dropped kept and printed
  • LIMIT scans its clause once for a top-level % directly followed by the end of the clause (end of input, ;, ), a set operator, OFFSET followed by a value, FETCH FIRST/NEXT); the Pratt loop stops at that token only. That % used to be a modulo missing its right operand, i.e. an error, so LIMIT 10 % 3, LIMIT a % offset + 1 (a column named offset) and modulos in nested sub-selects parse as before. After DuckDB's TABLESAMPLE n, OFFSET belongs to the query.
  • TableFunction implemented setSampleClause as a no-op; it now stores and prints the clause.
  • checkGrammarAmbiguity: no conflicts. ./gradlew check: 10,118 tests, 0 failures. On ~9,760 statements extracted from this repository's tests, results are identical to master.
  • DuckDB's own test suite (test/sql, 70,729 statements): 50 more parse, none less.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@guizmaii
guizmaii marked this pull request as ready for review October 13, 2026 09:45
Copilot AI balanced review requested due to automatic review settings October 13, 2026 09:45
Copilot AI reviewed Oct 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@guizmaii guizmaii mentioned this pull request Oct 13, 2026
DuckDB: remaining syntax to support #2804
Open
27 tasks
guizmaii added 2 commits October 13, 2026 21:46
@guizmaii
DuckDB: support LIMIT 10% and TABLESAMPLE without a method
7dd714b
- `LIMIT 10%` and `LIMIT 10 PERCENT` set the new `Limit.percentUnit`.
  Inside a LIMIT, a `%` followed by the end of the clause is the unit,
  not a modulo; `LIMIT 10 % 3` and `LIMIT a % offset` are unchanged.
- TABLESAMPLE takes DuckDB's optional method and reservoir, as USING
  SAMPLE already does: `TABLESAMPLE 10%`, `TABLESAMPLE reservoir(10 ROWS)`.
- A table function keeps and prints its sample clause: `range(10) r
  USING SAMPLE 10%` used to lose it.
@guizmaii
Find the percent of LIMIT 10% once and keep columns named offset
4566175
- LIMIT scans its clause once for the top-level % followed by its end,
  and the Pratt loop stops at that token only, so `LIMIT a % offset + 1`
  and modulos nested in sub-selects are unchanged.
- OFFSET ends the clause only before a value, FETCH only before FIRST or
  NEXT.
- After DuckDB's TABLESAMPLE n, OFFSET belongs to the query.
- The unit is printed after NULL and ALL too.
@guizmaii
guizmaii force-pushed the duckdb-limit-percent-tablesample branch from f26ed7f to 4566175 Compare October 13, 2026 10:50
@manticore-projects
manticore-projects merged commit 49b5ea9 into JSQLParser:master Oct 13, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@guizmaii
guizmaii deleted the duckdb-limit-percent-tablesample branch October 22, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@guizmaii @manticore-projects
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.