Skip to content

Commit

Permalink
[CALCITE-4188] Add hints from review
Browse files Browse the repository at this point in the history
  • Loading branch information
kramerul committed Jan 10, 2025
1 parent 0ef6249 commit 9e5755b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import org.checkerframework.checker.nullness.qual.Nullable;

import static java.lang.Integer.parseInt;

/**
* A special DataContext which handles correlation variable for batch nested loop joins.
*/
Expand All @@ -36,6 +38,7 @@ public JdbcCorrelationDataContext(DataContext delegate, Object[] parameters) {
this.delegate = delegate;
this.parameters = parameters;
}

@Override public @Nullable SchemaPlus getRootSchema() {
return delegate.getRootSchema();
}
Expand All @@ -50,7 +53,7 @@ public JdbcCorrelationDataContext(DataContext delegate, Object[] parameters) {

@Override public @Nullable Object get(String name) {
if (name.startsWith("?")) {
int index = Integer.parseInt(name.substring(1));
int index = parseInt(name.substring(1));
if (index >= OFFSET && index < OFFSET + parameters.length) {
return parameters[index - OFFSET];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public Result implement(RelNode node) {
return context;
}
List<RelDataTypeField> fieldList = variable.getType().getFieldList();
// We need to provide a context which also includes the correlation variables
// as dynamic parameters.
return new Context(dialect, fieldList.size()) {
@Override public SqlNode field(int ordinal) {
RelDataTypeField field = fieldList.get(ordinal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,10 @@ private LockWrapper exclusiveCleanDb(Connection c) throws SQLException {
.runs();
}

/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-4188">[CALCITE-4188]
* Support EnumerableBatchNestedLoopJoin for JDBC</a>. */
@Test void testBatchNestedLoopJoinPlan() {
final String sql = "SELECT *\n"
+ "FROM \"s\".\"emps\" A\n"
Expand Down

0 comments on commit 9e5755b

Please sign in to comment.