GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — DuckDB: support LIMIT 10% and TABLESAMPLE without a method by guizmaii · Pull Request #2802 · JSQLParser/JSqlParser Conversation
|
| 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 |
% 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.test/sql, 70,729 statements): 50 more parse, none less.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
- `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.
- 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.
f26ed7f to
4566175
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.