[ https://issues.apache.org/jira/browse/CALCITE-1822?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde updated CALCITE-1822: --------------------------------- Description: Push Aggregate that follows Aggregate down to Druid. This can occur if the SQL has an aggregate function applied to an aggregate function, or with a sub-query in the FROM clause. {code} SELECT MAX(COUNT(*)) FROM Emp GROUP BY deptno SELECT MAX(c) FROM ( SELECT deptno, COUNT(*) AS c FROM Emp GROUP BY deptno) {code} And there are other possibilities where there is a Project and/or a Filter after the first Aggregate and before the second Aggregate. [~bslim], you wrote: {quote} For instance in druid we can do select count distinct as an inner group by that group on the key and the outer one does then count. more complex cases is count distinct from unions of multiple queries {quote} Can you please write a SQL statement for each of those cases? was: Push Aggregate that follows Aggregate down to Druid. This can occur if the SQL has an aggregate function applied to an aggregate function, or with a sub-query in the FROM clause. {code} SELECT MAX(COUNT(*)) FROM Emp GROUP BY deptno SELECT MAX(c) FROM ( SELECT deptno, COUNT(*) AS c FROM Emp GROUP BY deptno) {code} And there are other possibilities where there is a Project and/or a Filter after the first Aggregate and before the second Aggregate. > Push Aggregate that follows Aggregate down to Druid > --------------------------------------------------- > > Key: CALCITE-1822 > URL: https://issues.apache.org/jira/browse/CALCITE-1822 > Project: Calcite > Issue Type: Bug > Components: druid > Reporter: Julian Hyde > Assignee: Julian Hyde > > Push Aggregate that follows Aggregate down to Druid. This can occur if the > SQL has an aggregate function applied to an aggregate function, or with a > sub-query in the FROM clause. > {code} > SELECT MAX(COUNT(*)) > FROM Emp > GROUP BY deptno > SELECT MAX(c) FROM ( > SELECT deptno, COUNT(*) AS c > FROM Emp > GROUP BY deptno) > {code} > And there are other possibilities where there is a Project and/or a Filter > after the first Aggregate and before the second Aggregate. > [~bslim], you wrote: > {quote} > For instance in druid we can do select count distinct as an inner group by > that group on the key and the outer one does then count. more complex cases > is count distinct from unions of multiple queries > {quote} > Can you please write a SQL statement for each of those cases? -- This message was sent by Atlassian JIRA (v6.3.15#6346)