[
https://issues.apache.org/jira/browse/CALCITE-7010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
suibianwanwan resolved CALCITE-7010.
------------------------------------
Fix Version/s: 1.41.0
Resolution: Fixed
> The well-known count bug
> ------------------------
>
> Key: CALCITE-7010
> URL: https://issues.apache.org/jira/browse/CALCITE-7010
> Project: Calcite
> Issue Type: Bug
> Reporter: suibianwanwan
> Assignee: suibianwanwan
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.41.0
>
>
> What is the count-bug: [Optimization of Nested SQL Queries
> Revisited|https://dl.acm.org/doi/pdf/10.1145/38714.38723]
> {quote}The well-known "count-bug" is not specific to the count aggregate, and
> outer-join does not solve it. The anomaly can occur on any aggregate
> function; aggregates need modification to distiguish empty set from null
> values; and optimizing out the outerjoin depends on utilization context
> {quote}
> Test in sub-query.iq:
> {code:java}
> SELECT deptno
> FROM dept d
> WHERE 0 IN (
> SELECT COUNT(*)
> FROM emp e
> WHERE d.deptno = e.deptno
> );
> +--------+
> | DEPTNO |
> +--------+
> | 40 |
> +--------+
> (1 row)
> !ok
> SELECT deptno
> FROM dept d
> WHERE 'Regular' IN (
> SELECT CASE WHEN SUM(sal) > 10 then 'VIP' else 'Regular' END expr
> FROM emp e
> WHERE d.deptno = e.deptno
> );
> +--------+
> | DEPTNO |
> +--------+
> | 40 |
> +--------+
> (1 row)
> !ok
> {code}
> Actual results:
> {code:java}
> +--------+
> | DEPTNO |
> +--------+
> +--------+
> (0 rows)
> +--------+
> | DEPTNO |
> +--------+
> +--------+
> (0 rows)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)