[
https://issues.apache.org/jira/browse/CALCITE-3310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16919513#comment-16919513
]
Danny Chan commented on CALCITE-3310:
-------------------------------------
The plan is wrong and the agg output should not be reused.
> Approximate and exact aggregate calls are recognized as the same during
> sql-to-rel conversion
> ---------------------------------------------------------------------------------------------
>
> Key: CALCITE-3310
> URL: https://issues.apache.org/jira/browse/CALCITE-3310
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.20.0
> Reporter: Danny Chan
> Assignee: Danny Chan
> Priority: Major
> Fix For: 1.21.0
>
>
> For sql:
> {code:sql}
> SELECT empno, count(distinct ename)
> approx_count_distinct(ename)
> FROM emp
> GROUP BY empno
> {code}
> After sql-to-rel conversion, the plan is:
> {code:sql}
> LogicalProject(EMPNO=[$0], EXPR$1=[$1], EXPR$2=[$1])
> LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)])
> LogicalProject(EMPNO=[$0], ENAME=[$1])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
--
This message was sent by Atlassian Jira
(v8.3.2#803003)