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: parse slices with omitted bounds or a step by guizmaii · Pull Request #2794 · JSQLParser/JSqlParser Conversation
|
| Input | Before | After |
|---|---|---|
l[2:3] |
JsonExpression 2 : 3 |
slice 2..3 |
l[:2] |
NumericBind :2 |
slice ..2 |
l[2:], l[:], l[-5:] |
parse error | slice |
l[1:5:2], l[1:-:2] (DuckDB step, - = end) |
wrong tree / error | slice with step |
: at the top level of a subscript (col[...], expr[...]), outside any brackets, braces, parentheses or CASE opened in it, separates slice bounds instead of starting a JSON path. JSON paths elsewhere are unchanged: c:a[1], l[(SELECT c:a FROM t)], l[f(c:a)], l[ARRAY[c:a]].l[:name] / l[:1] are now slices up to name / 1, no longer a JDBC named parameter / numeric bind; Snowflake's l[v:i] is now a slice. Both follow PostgreSQL and DuckDB slice syntax.RangeExpression (column subscripts) and ArrayExpression (other subscripts) gain a step and accept missing bounds. A missing stop before a step deparses as -, since l[1::2] would lex as a cast.TablesNamesFinderTraversalTest asserted the JsonExpression parse of f()[1:2]; it now asserts the slice bounds.checkGrammarAmbiguity: no conflicts. ./gradlew check: 10,121 tests, 0 failures.test/sql, 70,729 statements): 36 more parse, none less.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`l[2:]`, `l[:]` and `l[-5:]` failed, `l[2:3]` parsed as the JSON path `2 : 3` and `l[:2]` as the numeric bind `:2`. Inside a subscript, a `:` now separates the bounds of a slice rather than starting a JSON path. Slices also take DuckDB's optional step, `l[1:5:2]`, where a `-` stop stands for the end of the list, `l[1:-:2]`. `RangeExpression` and `ArrayExpression` gain a step and accept missing bounds.
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.
`l[(SELECT c:a FROM t)]`, `l[f(x, c:a)]` and `l[CASE WHEN c:a = 1 ...]` failed: the subscript depth disabled the JSON path operator in every expression nested in the subscript. Only a `:` at the subscript's own top level, outside brackets, braces, parentheses and CASE, now separates slice bounds.
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.