[
https://issues.apache.org/jira/browse/CALCITE-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17028278#comment-17028278
]
Rui Wang commented on CALCITE-3764:
-----------------------------------
Ah. I did more Calcite tests locally and now I get it:
Calcite does not convert FILTER for THEN ELSE unless it is a NULL value after
THEN, which actually makes sense. Now I agreed what the proposed solution (e.g.
convert to IS NOT TRUE) and it should work for other aggregation functions.
> AggregateCaseToFilterRule handles NULL values correctly
> -------------------------------------------------------
>
> Key: CALCITE-3764
> URL: https://issues.apache.org/jira/browse/CALCITE-3764
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Rui Wang
> Priority: Major
>
> {{AggregateCaseToFilterRule}} handles NULL values correctly. It converts
> {code:sql}
> SELECT COUNT(CASE WHEN b THEN NULL ELSE 1 END) FROM t
> {code}
> to
> {code:sql}
> SELECT COUNT(*) FILTER (WHERE b IS FALSE) FROM t
> {code}
> which fails to count rows where {{b}} is UNKNOWN, so it should convert to
> {code:sql}
> SELECT COUNT(*) FILTER (WHERE b IS NOT TRUE) FROM t
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)