Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chucheng92 committed Oct 27, 2023
1 parent 78d0288 commit c998265
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4934,6 +4934,30 @@ void checkUserDefinedOrderByOver(NullCollation nullCollation) {
.convertsTo("${planNotExpanded}");
}

/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6028"> [CALCITE-6028]
* SqlToRelConverter#substituteSubQuery gives NullPointerException when convert
* IN-subquery within JOIN if value size of IN exceeds IN_SUBQUERY_THRESHOLD</a>.
*/
@Test void testInSubQueryWithinJoin0() {
String sql = "SELECT t1.x FROM (values (1, 'a')) as t1(x, y)\n" +
"left join (values (1, 'b')) as t2(x, y)\n" +
"ON t1.x=t2.x AND t1.x IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)";
sql(sql).ok();
}

/**
* As {@link #testInSubQueryWithinJoin0()} but size of IN value list < 20
*/
@Test void testInSubQueryWithinJoin1() {
String sql = "SELECT t1.x FROM (values (1, 'a')) as t1(x, y)\n" +
"left join (values (1, 'b')) as t2(x, y)\n" +
"ON t1.x=t2.x AND t1.x IN (1,2,3,4,5)";
sql(sql).ok();
}


/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-4295">[CALCITE-4295]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,36 @@ FROM dept, emp WHERE emp.deptno = dept.deptno AND emp.sal < (
)]]>
</Resource>
</TestCase>
<TestCase name="testInSubQueryWithinJoin0">
<Resource name="sql">
<![CDATA[SELECT t1.x FROM (values (1, 'a')) as t1(x, y)
left join (values (1, 'b')) as t2(x, y)
ON t1.x=t2.x AND t1.x IN (1,2,3,4,5)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$0])
LogicalJoin(condition=[AND(=($0, $2), SEARCH($0, Sarg[1, 2, 3, 4, 5]))], joinType=[left])
LogicalValues(tuples=[[{ 1, 'a' }]])
LogicalValues(tuples=[[{ 1, 'b' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInSubQueryWithinJoin1">
<Resource name="sql">
<![CDATA[SELECT t1.x FROM (values (1, 'a')) as t1(x, y)
left join (values (1, 'b')) as t2(x, y)
ON t1.x=t2.x AND t1.x IN (1,2,3,4,5)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$0])
LogicalJoin(condition=[AND(=($0, $2), SEARCH($0, Sarg[1, 2, 3, 4, 5]))], joinType=[left])
LogicalValues(tuples=[[{ 1, 'a' }]])
LogicalValues(tuples=[[{ 1, 'b' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInToSemiJoin">
<Resource name="sql">
<![CDATA[SELECT empno
Expand Down

0 comments on commit c998265

Please sign in to comment.