[
https://issues.apache.org/jira/browse/CALCITE-5163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Chunwei Lei resolved CALCITE-5163.
----------------------------------
Fix Version/s: 1.31.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/52c9b7836bbed90038f28a933c0cb56d2d69cd28|https://github.com/apache/calcite/commit/52c9b7836bbed90038f28a933c0cb56d2d69cd28.].
Thank you for your PR, [~wojustme]!
> 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
> Labels: pull-request-available
> Fix For: 1.31.0
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> 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)