Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5163

MysqlSqlDialect unparse LISTAGG aggregate function error

    XMLWordPrintableJSON

Details

    Description

      CALCITE-4349 supports GROUP_CONCAT aggregate function. The code 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.

      // 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);
      }

      Attachments

        Issue Links

          Activity

            People

              wojustme Xurenhe
              wojustme Xurenhe
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h