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

libopeng commented on CALCITE-5568:
-----------------------------------

{code:java}
select ( SELECT 1 ) AS c1
from EMP t1
where EXISTS (select deptno from EMP t2 where t1.deptno=t2.deptno) {code}
Is this?

> Decorrelate will fail. If the RelNode tree has LogicalValues
> ------------------------------------------------------------
>
>                 Key: CALCITE-5568
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5568
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: libopeng
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Decorrelate will fail. If the RelNode tree has LogicalValues
> case:
> {code:java}
> SELECT
> ( SELECT COUNT(tbl2.deptno) FROM emp AS tbl2 WHERE tbl1.deptno = tbl2.deptno 
> ) AS c0,
> ( SELECT 1 ) AS c1
> FROM emp AS tbl1  {code}
> after decorrelate 
> (org.apache.calcite.sql2rel.RelDecorrelator#decorrelateQuery(org.apache.calcite.rel.RelNode,
>  org.apache.calcite.tools.RelBuilder))
> {code:java}
> LogicalProject(C0=[$9], C1=[$10])
>   LogicalJoin(condition=[true], joinType=[left])
>     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[CASE(IS NULL($9), 
> 0:BIGINT, $9)])
>       LogicalCorrelate(correlation=[$cor0], joinType=[left], 
> requiredColumns=[{7}])
>         LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>         LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
>           LogicalProject(DEPTNO=[$7])
>             LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
>               LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
>       LogicalValues(tuples=[[{ 1 }]]){code}
> LogicalCorrelate will not be processed when the RelNode tree has 
> LogicalValues 
> [https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java#L491]
>  
> Is this as expected?
>  
>  
>  
>  



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

Reply via email to