Silun Dong created CALCITE-7091:
-----------------------------------
Summary: Approximate of AggregateCall changes after applying
AggregateCaseToFilterRule
Key: CALCITE-7091
URL: https://issues.apache.org/jira/browse/CALCITE-7091
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.40.0
Reporter: Silun Dong
When AggregateCaseToFilterRule converts a CASE-style filter aggregate into a
true filter aggregate, the approximate of the generated true filter aggregate
is always false.
{code:java}
select APPROX_COUNT_DISTINCT(case when job = 'CLERK' then deptno else null end)
as count_distinct_clerk from emp
// init plan
LogicalAggregate(group=[{}], COUNT_DISTINCT_CLERK=[COUNT(APPROXIMATE DISTINCT
$0)])
LogicalProject($f0=[CASE(=($2, 'CLERK'), $7, null:INTEGER)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
// after
LogicalAggregate(group=[{}], COUNT_DISTINCT_CLERK=[COUNT(DISTINCT $0) FILTER
$1])
LogicalProject(DEPTNO=[$7], $f2=[=($2, 'CLERK')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]){code}
This looks like a bug.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)