Repository navigation
[CALCITE-7821] Correlated query crashes SqlToRelConverter #5291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2728,6 +2728,31 @@ void checkCorrelatedMapSubQuery(boolean expand) { | |
| sql(sql).ok(); | ||
| } | ||
|
|
||
| /** Test case for | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7821">[CALCITE-7821] | ||
| * Correlated query crashes SqlToRelConverter</a>. */ | ||
| @Test void testNotInCorrelatedNullable() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The checked-in plan is the decorrelated one, so the shape that |
||
| final String sql = "select * from emp as t where t.mgr not in" | ||
| + " (select s.mgr from emp as s where s.empno = t.empno)"; | ||
| sql(sql).withExpand(true).ok(); | ||
| } | ||
|
|
||
| /** As {@link #testNotInCorrelatedNullable()}, but without decorrelation. */ | ||
| @Test void testNotInCorrelatedNullableNoDecorrelate() { | ||
| final String sql = "select * from emp as t where t.mgr not in" | ||
| + " (select s.mgr from emp as s where s.empno = t.empno)"; | ||
| sql(sql).withExpand(true).withDecorrelate(false).ok(); | ||
| } | ||
|
|
||
| /** As {@link #testNotInCorrelatedNullable()}, but in HAVING, where the | ||
| * outer query is an aggregate. */ | ||
| @Test void testNotInCorrelatedNullableHaving() { | ||
| final String sql = "select deptno from emp as e group by deptno\n" | ||
| + "having deptno not in\n" | ||
| + " (select s.mgr from emp as s where s.deptno = e.deptno)"; | ||
| sql(sql).withExpand(true).ok(); | ||
| } | ||
|
|
||
| @Test void testAllValueList() { | ||
| final String sql = "select empno from emp where deptno > all (10, 20)"; | ||
| sql(sql).withExpand(false).ok(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same crash still happens when the outer query aggregates:
It fails with
AssertionError: Required columns {3, 7} not subset of left columns {0, 1, 2, 3}fromBlackboard.register→createJoin. TheINvariant and the uncorrelatedNOT INvariant both work.The new count join becomes
bb.root, but it has no entry inmapRootRelToFieldProjection. As a result,getCorrelationUsefor the second join takes the column positions from before the aggregate. With the following lines beforebb.setRoot, the query produces a valid plan both with and without decorrelation:Could you add this query as a test too?