[ https://issues.apache.org/jira/browse/CALCITE-5163 ]


    Xurenhe deleted comment on CALCITE-5163:
    ----------------------------------

was (Author: wojustme):
Hi guys, PR has been ready, welcome to review it.

https://github.com/apache/calcite/pull/2812

> MysqlSqlDialect unparse LISTAGG aggregate function error
> --------------------------------------------------------
>
>                 Key: CALCITE-5163
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5163
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Xurenhe
>            Assignee: Xurenhe
>            Priority: Major
>
> CALCITE-4349 supports GROUP_CONCAT aggregate function. [The 
> code|https://github.com/apache/calcite/blob/7c1e2746b94a50f0bb08571287acb5327fdc1b16/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L5746]
>  translated *GROUP_CONCAT* to *LISTAGG* during sql_to_rel.
> But, *MysqlSqlDialect* keep *LISTAGG* after uparsing query's relnode, the 
> result sql couldn't be executed in MySQL engine.
>  
> I expect the following test case to be successful, but it's failed.
> {code:java}
> // test in org.apache.calcite.rel.rel2sql.RelToSqlConverterTest
> @Test void testMySqlGroupConcat() {
>   final String query = "select\n"
>       + "listagg(distinct \"product_name\", ',') within group(order by 
> \"cases_per_pallet\")"
>       + "from \"product\"\n"
>       + "group by \"product_id\"\n";
>   final String expected = "SELECT GROUP_CONCAT(DISTINCT `product_name` ORDER 
> BY "
>       + "`cases_per_pallet` IS NULL, `cases_per_pallet` SEPARATOR ',')\n"
>       + "FROM `foodmart`.`product`\n"
>       + "GROUP BY `product_id`";
>   sql(query).withMysql().ok(expected);
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to