Steven Talbot created CALCITE-3097:
--------------------------------------

             Summary: GROUPING SETS breaks on sets of size > 1 due to 
precedence issues
                 Key: CALCITE-3097
                 URL: https://issues.apache.org/jira/browse/CALCITE-3097
             Project: Calcite
          Issue Type: Bug
            Reporter: Steven Talbot


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.
{code:java}
/** 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);
}{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to