Description
distinct column is redundant because count has distinct.
select count(distinct x) cnt from( select distinct sal x from emp ) t
PlanBefore is
LogicalAggregate(group=[{}], CNT=[COUNT(DISTINCT $0)]) LogicalAggregate(group=[{5}]) LogicalTableScan(table=[[CATALOG, SALES, EMP]])
PlanAfter should be
LogicalAggregate(group=[{}], CNT=[COUNT(DISTINCT $5)]) LogicalTableScan(table=[[CATALOG, SALES, EMP]])
But `CoreRules.AGGREGATE_MERGE` not support it, we can improve it.
Attachments
Issue Links
- is duplicated by
-
CALCITE-6214 Remove DISTINCT in aggregate function if field is unique
- Closed