You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "libopeng (Jira)" <ji...@apache.org> on 2023/05/30 11:12:00 UTC
[jira] [Comment Edited] (CALCITE-5568) Decorrelate will fail. If the RelNode tree has LogicalValues
[ https://issues.apache.org/jira/browse/CALCITE-5568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727482#comment-17727482 ]
libopeng edited comment on CALCITE-5568 at 5/30/23 11:11 AM:
-------------------------------------------------------------
{code:java}
with parts (PNum, OrderOnHand) as (select * from (values (3, 6), (10, 1), (8, 0)) as t(PNum, OrderOnHand)),
supply (PNum, Qty) as (select * from (values (3, 4), (3, 2), (10, 1)))
select pnum
from parts p
where orderOnHand in (select count(*) from supply s where s.pnum = p.pnum);{code}
{code:java}
EnumerableCalc(expr#0..1=[{inputs}], PNUM=[$t0])
EnumerableHashJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[semi])
EnumerableValues(tuples=[[{ 3, 6 }, { 10, 1 }, { 8, 0 }]])
EnumerableSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
EnumerableAggregate(group=[{0}], EXPR$0=[COUNT()])
EnumerableValues(tuples=[[{ 3 }, { 3 }, { 10 }]]) {code}
[~zabetak] Is the plan wrong? I don't know the physical execution plan for semi join.
was (Author: JIRAUSER298961):
{code:java}
with parts (PNum, OrderOnHand) as (select * from (values (3, 6), (10, 1), (8, 0)) as t(PNum, OrderOnHand)),
supply (PNum, Qty) as (select * from (values (3, 4), (3, 2), (10, 1)))
select pnum
from parts p
where orderOnHand in (select count(*) from supply s where s.pnum = p.pnum);{code}
{code:java}
EnumerableCalc(expr#0..1=[{inputs}], PNUM=[$t0])
EnumerableHashJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[semi])
EnumerableValues(tuples=[[{ 3, 6 }, { 10, 1 }, { 8, 0 }]])
EnumerableSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
EnumerableAggregate(group=[{0}], EXPR$0=[COUNT()])
EnumerableValues(tuples=[[{ 3 }, { 3 }, { 10 }]]) {code}
[~zabetak] Is the plan wrong?I don't know.
> 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 *
> FROM emp AS e
> CROSS JOIN (VALUES 1) AS t (x)
> WHERE EXISTS (SELECT * FROM dept WHERE deptno = e.deptno){code}
> after decorrelate (org.apache.calcite.sql2rel.RelDecorrelator#decorrelateQuery(org.apache.calcite.rel.RelNode, org.apache.calcite.tools.RelBuilder))
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], X=[$9])
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], X=[$9], $f0=[$10])
> LogicalFilter(condition=[IS NOT NULL($10)])
> LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
> LogicalJoin(condition=[true], joinType=[inner])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> LogicalValues(tuples=[[{ 1 }]])
> LogicalAggregate(group=[{}], agg#0=[MIN($0)])
> LogicalProject($f0=[true])
> LogicalFilter(condition=[=($0, $cor0.DEPTNO)])
> LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
> {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)