[
https://issues.apache.org/jira/browse/CALCITE-5568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17728636#comment-17728636
]
libopeng commented on CALCITE-5568:
-----------------------------------
{code:java}
SELECT `t0`.`_c0`
FROM (
SELECT `t`.`_c0`, `t`.`_c1`
FROM (select 1 ,2
union all
select 10 ,1
union all
select 8 , 0
) AS `t`
) AS `t0`
left semi JOIN (
SELECT `t1`.`_c0`, COUNT(*) AS `f1`
FROM (
select 3 , 4
union all
select 3 , 2
union all
select 10 , 1
) AS `t1`
GROUP BY `t1`.`_c0`
) AS `t4` ON `t0`.`_c0` = `t4`.`_c0` AND `t0`.`_c1` = `t4`.`f1`; {code}
result
{code:java}
+------+
| _c0 |
+------+
| 10 |
+------+ {code}
I tested the sql corresponding to this plan in the hive, and the result was
indeed wrong. But I'm sure this error has nothing to do with values, it
probably has to do with count.
> 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)