[
https://issues.apache.org/jira/browse/CALCITE-7010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17985171#comment-17985171
]
Mihai Budiu edited comment on CALCITE-7010 at 6/22/25 5:08 PM:
---------------------------------------------------------------
I don't see how this can be right; the plan joins ON DEPTNO = DNAME; DNAME is
not used in the original plan. I suspect that some offset is wrong in the join
field index computation.
was (Author: JIRAUSER295926):
I don't see how this can be right; the plan joins ON DEPTNO = DEPT; DEPT is not
used in the original plan. I suspect that some offset is wrong in the join
field index computation.
> 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)