[ 
https://issues.apache.org/jira/browse/CALCITE-4726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17399950#comment-17399950
 ] 

Julian Hyde edited comment on CALCITE-4726 at 9/3/21, 12:54 AM:
----------------------------------------------------------------

I think it's a better idea to just count group cardinalities whenever there's a 
filter. The unique semantics of {{COUNT\(\*)}} makes {{ignoreNulls}} 
un-intuitive; you would probably want to say that {{COUNT}} always ignores 
nulls, it's just that {{COUNT\(\*)}} would never encounter a null, but since we 
reduce {{COUNT(a)}} to {{COUNT\(\*)}} in a number of places (including 
{{AggregateReduceFunctionsRule}}), we can't always depend on the argument to 
reference it's true "intentional" column. Doing it this way also makes the rule 
more robust against regressions where we forget to set {{ignoreNulls}} 
correctly.

Other than that, feedback incorporated as suggested.


was (Author: wnoble):
I think it's a better idea to just count group cardinalities whenever there's a 
filter. The unique semantics of {{COUNT(*)}} makes {{ignoreNulls}} 
un-intuitive; you would probably want to say that {{COUNT}} always ignores 
nulls, it's just that {{COUNT(*)}} would never encounter a null, but since we 
reduce {{COUNT(a)}} to {{COUNT(*)}} in a number of places (including 
{{AggregateReduceFunctionsRule}}), we can't always depend on the argument to 
reference it's true "intentional" column. Doing it this way also makes the rule 
more robust against regressions where we forget to set {{ignoreNulls}} 
correctly.

Other than that, feedback incorporated as suggested.

> Add support for filters in AggregateExpandWithinDistinctRule
> ------------------------------------------------------------
>
>                 Key: CALCITE-4726
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4726
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Will Noble
>            Assignee: Will Noble
>            Priority: Blocker
>
> Currently, {{AggregateExpandWithinDistinctRule}} does not fire if any of the 
> aggregate calls in the aggregate have a filter. We should support filters.
> For example, the following query will not be handled by the current rule due 
> to the {{FILTER}} clause:
> {code:java}
> SELECT deptno,
>     SUM(sal),
>     SUM(sal) WITHIN DISTINCT (job) FILTER (WHERE ename LIKE 'A%')
> FROM emp
> GROUP BY deptno
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to