Skip to content

Commit

Permalink
[CALCITE-5409] Add suggested changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
kramerul committed Jan 21, 2025
1 parent 9e5755b commit 8587f30
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* A special DataContext which handles correlation variable for batch nested loop joins.
*/
public class JdbcCorrelationDataContext implements DataContext {
public static final int OFFSET = 10000;
public static final int OFFSET = Integer.MAX_VALUE - 10000;

private final DataContext delegate;
private final Object[] parameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
import java.lang.reflect.Type;

/**
* A class to build an object of type JdbcCorrelationDataContext.
* An interface to collect all correlation variables
* required to create a JdbcCorrelationDataContext.
*/
public interface JdbcCorrelationDataContextBuilder {
interface JdbcCorrelationDataContextBuilder {
/**
* Collect a correlation variable.
*/
int add(CorrelationId id, int ordinal, Type type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public class JdbcImplementor extends RelToSqlConverter {
private final JdbcCorrelationDataContextBuilder dataContextBuilder;
private final JavaTypeFactory typeFactory;

public JdbcImplementor(SqlDialect dialect, JavaTypeFactory typeFactory,
JdbcImplementor(SqlDialect dialect, JavaTypeFactory typeFactory,
JdbcCorrelationDataContextBuilder dataContextBuilder) {
super(dialect);
this. typeFactory = typeFactory;
this.typeFactory = typeFactory;
this.dataContextBuilder = dataContextBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.calcite.rel.rel2sql;

import org.apache.calcite.adapter.jdbc.JdbcCorrelationDataContext;
import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.linq4j.tree.Expressions;
Expand Down Expand Up @@ -767,6 +768,11 @@ public SqlNode toSql(@Nullable RexProgram program, RexNode rex) {

case DYNAMIC_PARAM:
final RexDynamicParam caseParam = (RexDynamicParam) rex;
if (caseParam.getIndex() >= JdbcCorrelationDataContext.OFFSET) {
throw new AssertionError("More than "
+ JdbcCorrelationDataContext.OFFSET
+ " dynamic parameters used in query");
}
return new SqlDynamicParam(caseParam.getIndex(), POS);

case IN:
Expand Down

0 comments on commit 8587f30

Please sign in to comment.