Skip to content

Commit

Permalink
[CALCITE-3651] NPE when convert relational algebra that correlates Ta…
Browse files Browse the repository at this point in the history
…bleFunctionScan (Wang Yanlin)
  • Loading branch information
yanlin-Lynn authored and hsyuan committed Jan 3, 2020
1 parent 7dcceee commit 3dd6d85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,7 @@ public Result visit(TableFunctionScan e) {
SqlNode select = new SqlSelect(
SqlParserPos.ZERO, null, null, tableCall,
null, null, null, null, null, null, null, SqlNodeList.EMPTY);
Result x = new Result(select,
ImmutableList.of(Clause.SELECT), null, e.getRowType(), null);
return x;
return result(select, ImmutableList.of(Clause.SELECT), e, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3734,6 +3734,19 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-3651">[CALCITE-3651]
* NullPointerException when convert relational algebra that correlates TableFunctionScan</a>. */
@Test public void testLateralCorrelate() {
final String query = "select * from \"product\",\n"
+ "lateral table(RAMP(\"product\".\"product_id\"))";
final String expected = "SELECT *\n"
+ "FROM \"foodmart\".\"product\" AS \"$cor0\",\n"
+ "LATERAL (SELECT *\n"
+ "FROM TABLE(RAMP(\"$cor0\".\"product_id\"))) AS \"t\"";
sql(query).ok(expected);
}

@Test public void testUncollectExplicitAlias() {
final String sql = "select did + 1 \n"
+ "from unnest(select collect(\"department_id\") as deptid"
Expand Down

0 comments on commit 3dd6d85

Please sign in to comment.