[
https://issues.apache.org/jira/browse/CALCITE-3097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16850248#comment-16850248
]
Julian Hyde commented on CALCITE-3097:
--------------------------------------
The problem was not with precedence; it was that each composite element in
GROUPING SETS should be a SqlCall to the ROW operator rather than a
SqlNodeList. See
https://github.com/julianhyde/calcite/commit/abe20d5052065151028f543a2c55f25b5a5da39b.
> 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
> Components: jdbc-adapter
> Reporter: Steven Talbot
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.20.0
>
>
> 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)