[ 
https://issues.apache.org/jira/browse/CALCITE-5100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114918#comment-18114918
 ] 

Hanumath Rao Maduri commented on CALCITE-5100:
----------------------------------------------

This issue is fixed by {*}CALCITE-4702 (1.30.0){*}. The constant separator in 
{{{}GROUP BY{}}}, which PostgreSQL rejects, is now transformed into a dummy 
{{(VALUES ...)}} join and grouped by column, based on 
{{SqlDialect.supportsGroupByLiteral()}} (which returns {{false}} for 
PostgreSQL).

Verified by comparing:
 * *Parent of CALCITE-4702:* {{GROUP BY "C11", "C12", ', '}}

 * *CALCITE-4702:* {{(VALUES (', ')) ... GROUP BY ..., "t"."$f2"}}

The change is available in 
[CALCITE-4702|https://github.com/apache/calcite/pull/2482/changes].

Additionally, *CALCITE-6866 (1.40.0)* unparses {{LISTAGG}} to 
{{{}STRING_AGG{}}}, making the complete statement valid for PostgreSQL.

Resolving as {*}Fixed{*}.

> Incorrect syntax in sub-query, unsupported LISTAGG
> --------------------------------------------------
>
>                 Key: CALCITE-5100
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5100
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.30.0
>            Reporter: Roman Churganov
>            Priority: Blocker
>
> Execute query like: 
> {code:sql}
>   select C11, LISTAGG( distinct C12, ', ' )  
>          from FOO  
>          group by C11
> {code}
> In case of JDBC driver doesn't support LISTAGG function (Postresql),  JDBC 
> adapter creates subquery:
> {code:sql}
> SELECT "C11", "C12", ', ' AS "$f2"
>      FROM "FOO"
>      GROUP BY "C11", "C12", ', ' 
> {code}
> which cannot be executed on Postresql and gives error  :
> {noformat}
>    [42601] ERROR: non-integer constant in GROUP BY
> {noformat}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to