gianm opened a new pull request, #18498: URL: https://github.com/apache/druid/pull/18498
The rule is adapted from Calcite's AggregateMergeRule, with two changes: 1) Includes a workaround for https://issues.apache.org/jira/browse/CALCITE-7162 2) Includes the ability to merge two Aggregate with a Project between them, by pushing the Project below the new merged Aggregate. The goal is to rewrite a query like: ```sql SELECT MIN(t1.mn) mn, MAX(t1.mx) mx, UPPER(t1.x) x, SUM(t1.cnt) cnt, hr FROM ( SELECT floor(__time to hour) hr, COUNT(*) cnt, dim2 x, MIN(m1 * 5) mn, MAX(m1 + m2) mx" FROM druid.foo" WHERE dim2 IN ('abc', 'def', 'a', 'b', '') GROUP BY floor(__time to hour), dim2 ) t1 WHERE t1.x IN ('abc', 'foo', 'bar', 'a', '') GROUP BY UPPER(t1.x), hr ``` Into: ```sql SELECT MIN(t1.mn) mn, MAX(t1.mx) mx, UPPER(t1.x) x, SUM(t1.cnt) cnt, FLOOR(__time TO hour) hr FROM druid.foo WHERE t1.x IN ('abc', 'a', '') GROUP BY UPPER(t1.x), FLOOR(__time TO hour) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
