Skip to content

fix: support FILTER after ordered-set aggregates - #2655

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/ordered-set-aggregate-filter
Sep 21, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/ordered-set-aggregate-filter

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

Valid PostgreSQL expressions such as percentile_cont(0.5) WITHIN GROUP (ORDER BY score) FILTER (WHERE active) currently fail to parse. Accept FILTER after WITHIN GROUP and render it in that position in both AST and visitor output, while preserving ordinary aggregate/window FILTER behavior.

Reuse AnalyticExpression and share filter parsing/rendering helpers. In the PostgreSQL dialect, reject the reversed FILTER-before-WITHIN-GROUP form. Tests cover ordered-set and hypothetical-set aggregates, filter/order expression visitors, malformed predicates, and window regressions.

Syntax reference: PostgreSQL aggregate expressions.

Validation:

  • Java 17 Gradle check: 7,820 XML-reported tests, 0 failures/errors, 25 skipped; formatting, grammar ambiguity, Checkstyle, PMD, and JMH compilation passed. Formatting was checked against upstream/master using a local Spotless ratchet override.
  • Actual PostgreSQL 17.11 server: 8 accepted and 5 rejected SQL cases matched the expected behavior.
  • Executed both AST and StatementDeParser output for the accepted cases on the same server: 16 successful executions.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 0db9e0e into JSQLParser:master Sep 21, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants