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 list comprehensions by guizmaii · Pull Request #2798 · 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 list comprehensions (docs):

SELECT [x * 2 FOR x IN l IF x > 1], [x + i FOR x, i IN l] FROM t
  • New ListComprehension expression: element expression, one or two variables (element, 1-based index), list expression, optional IF condition.
  • A [ opens a comprehension only when FOR follows at its top level (isListComprehensionAhead(), one pass over the token chain; a 20,000-element array parses as fast as on master); every other [ is still an ArrayConstructor. [... FOR ...] was a syntax error in every dialect, so nothing that parsed before changes. SQL Server's [name] quoting is lexed before this and unaffected.
  • ExpressionVisitor.visit(ListComprehension) is a default method visiting the element, list and condition, so existing visitors keep compiling. The deparser, adapter, validator and TablesNamesFinder implement it (tables in a sub-select list are found).
  • checkGrammarAmbiguity: no conflicts. ./gradlew check: 10,120 tests, 0 failures.
  • DuckDB's own test suite (test/sql, 70,729 statements): 91 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 08:57
Copilot AI balanced review requested due to automatic review settings October 13, 2026 08:57
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
guizmaii force-pushed the duckdb-list-comprehension branch 3 times, most recently from 327524b to bb13af8 Compare October 13, 2026 21:48
guizmaii added 2 commits October 14, 2026 08:55
@guizmaii
DuckDB: support list comprehensions
63e3a8f
`[x * 2 FOR x IN l IF x > 1]` and `[x + i FOR x, i IN l]` parse as the
new `ListComprehension`. A `[` opens one when a `FOR` follows at its top
level; any other `[` is still an array. `visit(ListComprehension)` is a
default method that visits the element, list and condition, so existing
`ExpressionVisitor` implementations keep compiling.
@guizmaii
Scan an array once to tell a list comprehension apart
75371f7
`isListComprehensionAhead()` called `getToken(i)` for each token, which
walks from the current token every time: parsing a 10,000-element array
took seconds. It now follows the token chain.
@guizmaii
guizmaii force-pushed the duckdb-list-comprehension branch from bb13af8 to 75371f7 Compare October 13, 2026 21:57
@manticore-projects
manticore-projects merged commit e7a5a43 into JSQLParser:master Oct 13, 2026
10 checks passed

Uh oh!

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

@manticore-projects

manticore-projects commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Thank you much!

All reactions

Sorry, something went wrong.

Uh oh!

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

@guizmaii
guizmaii deleted the duckdb-list-comprehension 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.