[ 
https://issues.apache.org/jira/browse/CALCITE-1583?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xiong duan resolved CALCITE-1583.
---------------------------------
    Fix Version/s: 1.41.0
       Resolution: Fixed

> Wrong results for query with correlated subqueries with aggregate subquery 
> expression
> -------------------------------------------------------------------------------------
>
>                 Key: CALCITE-1583
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1583
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Vineet Garg
>            Assignee: xiong duan
>            Priority: Major
>              Labels: pull-request-available, sub-query
>             Fix For: 1.41.0
>
>
> Following query produces wrong result:
> {code} select * from depts where exists (select sum(empno) from emps where 
> depts.deptno = emps.deptno and 1=2) {code}
> Expected Result:
> {noformat}
> deptno |   name    
> --------+-----------
>      10 | Sales
>      20 | Marketing
>      30 | Accounts
> (3 rows)
> {noformat}
> Actual results
> {noformat} zero rows {noformat}
> Calcite rewrites such queries into JOIN which ignores the fact that aggregate 
> functions such as {{sum}} always produce one row, effectively making 
> {{EXISTS}} predicate always true.
> Same is the case with {{Scalar}} and {{IN}} sub-queries.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to