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

Julian Hyde commented on CALCITE-4833:
--------------------------------------

The precise scenario seems to be a correlated scalar sub-query in the {{ON}} 
clause of a join. (Does the problem only occur if it is an outer join?) 

Regarding code organization. I can't see the bottom of the stack but I guess 
this error happens during SQL-to-Rel conversion. If so, a natural place for the 
test would be {{SqlToRelConverterTest}}. I think it would be sufficient if the 
test checks the plan; we don't need to run the query. Maybe add one test to 
sub-query.iq so we see this working end-to-end.

The fix doesn't look useful. It converts a trivial correlated scalar sub-query 
into an expression. No one would write such a thing (unless they are a QA 
engineer). The problem of correlated scalar sub-queries in ON remains.

> Complex nested correlated subquery failed.
> ------------------------------------------
>
>                 Key: CALCITE-4833
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4833
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.27.0
>            Reporter: Evgeny Stanilovsky
>            Assignee: Evgeny Stanilovsky
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.28.0
>
>         Attachments: test.patch
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Query like:
> {noformat}
> SELECT t1.empid FROM emps t1 LEFT JOIN emps t2 ON (SELECT t2.empid)<=100
> {noformat}
> failed with :
> {noformat}
> Required columns {5} not subset of left columns {0}
> java.lang.AssertionError: Required columns {5} not subset of left columns {0}
>       at org.apache.calcite.util.Litmus$1.fail(Litmus.java:32)
>       at org.apache.calcite.util.Litmus$1.check(Litmus.java:44)
>       at org.apache.calcite.rel.core.Correlate.isValid(Correlate.java:127)
>       at org.apache.calcite.rel.core.Correlate.<init>(Correlate.java:104)
>       at 
> org.apache.calcite.rel.logical.LogicalCorrelate.<init>(LogicalCorrelate.java:66)
>       at 
> org.apache.calcite.rel.logical.LogicalCorrelate.create(LogicalCorrelate.java:94)
> {noformat}
> failed test attached.
> The equal request forks fine:
> {noformat}
> SELECT t1.empid FROM emps t1 LEFT JOIN emps t2 ON t2.empid<=100
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to