[
https://issues.apache.org/jira/browse/CALCITE-7091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18003996#comment-18003996
]
Silun Dong commented on CALCITE-7091:
-------------------------------------
I found that in this rule, when generating a true filter aggregate, the field
{{{}distinct{}}}, {{{}approximate{}}}, {{ignoreNulls}} are always manually
specified. Is this reasonable?
In addition, why is it that when distinct is true, only the count function can
be converted?
> 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
> Priority: Minor
>
> 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)