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

GROUPING SETS breaks on sets of size > 1 due to precedence issues

    XMLWordPrintableJSON

Details

    Description

      Easiest to explain in a test. The test on current master fails, with relevant part of the parsed and unparsed query turning into something like `GROUP BY GROUPING SETS("product_class_id", "brand_name", "product_class_id")`, incorrectly flattening the sub lists of group sets into one long list.

      /** Tests that GROUPING SETS parse and unparse properly, especially that they maintain proper precedence
       * around nested lists. */
      @Test public void testGroupByGroupingSets() {
       final String query = "select \"product_class_id\", \"brand_name\"\n"
       + "from \"product\"\n"
       + "group by GROUPING SETS ((\"product_class_id\", \"brand_name\"), (\"product_class_id\"))\n"
       + "order by 2, 1";
       final String expected = "SELECT \"product_class_id\", \"brand_name\"\n" +
       "FROM \"foodmart\".\"product\"\n" +
       "GROUP BY GROUPING SETS((\"product_class_id\", \"brand_name\"), (\"product_class_id\"))\n" +
       "ORDER BY \"brand_name\", \"product_class_id\"";
       sql(query)
       .withPostgresql()
       .ok(expected);
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              swtalbot Steven Talbot
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: