Skip to content

[BUG] JSQLParser : PostgreSQL : GROUP BY DISTINCT with GROUPING SETS fails to parse #2785

Open

Description

@tomershay88

PostgreSQL supports GROUP BY DISTINCT with GROUPING SETS. The DISTINCT modifier removes duplicate grouping sets before processing (PostgreSQL documentation).

JSQLParser fails to parse this query.

SQL Example

SELECT 1 GROUP BY DISTINCT GROUPING SETS ((1), (1));

This query executes successfully in PostgreSQL and returns: 1

Parsing error

JSQLParser throws the following exception:

ParseException: Encountered:, at line 1, column 19, in lexical state DEFAULT.

The error is reported at DISTINCT, immediately after GROUP BY.

Tested with JSQLParser 5.4-SNAPSHOT.

Activity

  1. fudianchn commented on Oct 13, 2026

    @fudianchn
    Contributor

    First time seeing this cursed syntax — I'm off to figure out what it's actually useful for.

  2. manticore-projects commented on Oct 13, 2026

    @manticore-projects
    Contributor

    @fudianchn I do agree.

    I am sorry for asking bluntly: do we really want to support just anything or should we ask ourselves first "Why is it there and what value does it add"?

    We lost 10% of performance between last release and current snapshot already from adding functions.
    I feel like any further sacrifice should be well justified by a practical use-case.

    (And I have strong prejudice against non-portable SQL.)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions