You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2025/02/27 07:59:00 UTC

[jira] [Commented] (CALCITE-6866) PostgreSQLDialect support to unparse LISTAGG aggregate function

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

xiong duan commented on CALCITE-6866:
-------------------------------------

BigQueryDialect has the same problem.

> PostgreSQLDialect support to unparse LISTAGG aggregate function
> ---------------------------------------------------------------
>
>                 Key: CALCITE-6866
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6866
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: xiong duan
>            Priority: Major
>
> The unit test in RelToSqlConverterTest:
> {code:java}
> @Test void testPostgresqlLISTAGG() {
>   final String query = "SELECT \"product_class_id\","
>       + "LISTAGG(DISTINCT CAST(\"brand_name\" AS VARCHAR), ',') "
>       + "FROM \"foodmart\".\"product\" group by \"product_class_id\"";
>   sql(query).withPostgresql().ok("SELECT \"product_class_id\", LISTAGG(DISTINCT CAST(\"brand_name\" AS VARCHAR), ',')\n"
>       + "FROM \"foodmart\".\"product\"\nGROUP BY \"product_class_id\"");
> } {code}
> The generated SQL throws an exception in PG:
> {code:java}
> SELECT  "sex",  LISTAGG(DISTINCT CAST("patient"."id" AS VARCHAR), ',') AS "list"FROM  "patient"GROUP BY  "sex" {code}
> LISTAGG should be STRING_AGG.



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