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

PostgreSQLDialect support to unparse LISTAGG aggregate function

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.40.0
    • None

    Description

      The unit test in RelToSqlConverterTest:

      @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\"");
      } 

      The generated SQL throws an exception in PG:

      SELECT  "sex",  LISTAGG(DISTINCT CAST("patient"."id" AS VARCHAR), ',') AS "list"FROM  "patient"GROUP BY  "sex" 

      LISTAGG should be STRING_AGG.

      Attachments

        Issue Links

          Activity

            People

              xuzifu666 Yu Xu
              nobigo xiong duan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: