[ https://issues.apache.org/jira/browse/CALCITE-3977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17110241#comment-17110241 ]
Ruben Q L commented on CALCITE-3977: ------------------------------------ Thanks for your interest [~danny0405]. In fact, if we try to build the scenario using SQL (instead of RelBuilder, as the tests described so far in the current ticket), we get a very descriptive {{UnsupportedOperationException}}: {code} class java.lang.String: correlation on structured type java.lang.UnsupportedOperationException: class java.lang.String: correlation on structured type {code} Test case (in SqlToRelConverterTest): {code} @Test void testInnerJoinLateralOnStructuredType() { final String sql = "SELECT e1.empno, e2.empno FROM\n" + " (SELECT empno, home_address FROM emp_address WHERE empno=1) e1\n" + " INNER JOIN LATERAL\n" + " (SELECT empno FROM emp_address\n" + " WHERE empno<>e1.empno AND emp_address.home_address.city=e1.home_address.city)\n" + " e2 ON true"; sql(sql).ok(); } {code} > RelDecorrelator does not resolve correlation variable with field accesses > ------------------------------------------------------------------------- > > Key: CALCITE-3977 > URL: https://issues.apache.org/jira/browse/CALCITE-3977 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.22.0 > Reporter: Thomas Rebele > Priority: Major > Attachments: Calcite3977.java > > > The RelCorrelator seems to have problems with some plans that contain a field > access (probably a RexFieldAccess, but I haven't looked further into it). In > this ticket there's a filter on *$cor0.birthPlace.city*. > Here the complete plan: > {code:java} > before decorrelate > LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{}]) > LogicalTableScan(table=[[bookstore, authors]]) > LogicalFilter(condition=[=('Munich', $cor0.birthPlace.city)]) > LogicalTableScan(table=[[bookstore, authors]]) > after decorrelate > LogicalJoin(condition=[=($2, $8)], joinType=[left]) > LogicalTableScan(table=[[bookstore, authors]]) > LogicalJoin(condition=[true], joinType=[inner]) > LogicalFilter(condition=[=('Munich', $cor0.birthPlace.city)]) > LogicalTableScan(table=[[bookstore, authors]]) > LogicalAggregate(group=[{0}]) > LogicalProject(birthPlace=[$2]) > LogicalTableScan(table=[[bookstore, authors]]) > {code} > There seem to be two problems: > * The LogicalCorrelate has been removed, but the $cor0.birthPlace.city is > still in the filter condition. > * The inner join does not seem to be necessary. If it is, could somebody > explain, why? -- This message was sent by Atlassian Jira (v8.3.4#803005)