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: parse slices with omitted bounds or a step by guizmaii · Pull Request #2794 · 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, whose lists and strings support slices with omitted bounds and a step (docs).

Inside a subscript, : was read as the Snowflake JSON path operator, so slices did not parse as slices:

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
  • A : 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]].
  • Behaviour changes inside a subscript: 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.
  • DuckDB's own test suite (test/sql, 70,729 statements): 36 more parse, none less.

Sorry, something went wrong.

Uh oh!

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

All reactions
@guizmaii
Parse slices with omitted bounds or a step
4ac1d1b
`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.
Copilot AI balanced review requested due to automatic review settings October 13, 2026 07:56
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 marked this pull request as draft October 13, 2026 07:58
@guizmaii guizmaii changed the title Parse slices with omitted bounds or a step DuckDB: parse slices with omitted bounds or a step Oct 13, 2026
@guizmaii
Keep JSON paths nested inside a subscript
83ca164
`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.
@guizmaii
guizmaii marked this pull request as ready for review October 13, 2026 08:06
@guizmaii guizmaii mentioned this pull request Oct 13, 2026
DuckDB: remaining syntax to support #2804
Open
27 tasks
@manticore-projects
manticore-projects merged commit aa9ecfe 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-slices branch October 22, 2026 23:05
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.