Skip to content

Commit

Permalink
[CALCITE-3723] Following the change to add hints to RelNode, deprecat…
Browse files Browse the repository at this point in the history
…e the old constructors

Constructors for `Project`, `TableScan`, `Calc`, `Aggregate` and `Join`
introduce new parameter named "hints" which is a breaking change.
  • Loading branch information
danny0405 committed Jan 13, 2020
1 parent 536d503 commit 5cfd8c3
Show file tree
Hide file tree
Showing 47 changed files with 149 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.util.Pair;

import com.google.common.collect.ImmutableList;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -39,7 +41,7 @@
public class CassandraProject extends Project implements CassandraRel {
public CassandraProject(RelOptCluster cluster, RelTraitSet traitSet,
RelNode input, List<? extends RexNode> projects, RelDataType rowType) {
super(cluster, traitSet, input, projects, rowType);
super(cluster, traitSet, ImmutableList.of(), input, projects, rowType);
assert getConvention() == CassandraRel.CONVENTION;
assert getConvention() == input.getConvention();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.apache.calcite.rel.core.TableScan;
import org.apache.calcite.rel.type.RelDataType;

import com.google.common.collect.ImmutableList;

import java.util.List;

/**
Expand All @@ -45,7 +47,7 @@ public class CassandraTableScan extends TableScan implements CassandraRel {
*/
protected CassandraTableScan(RelOptCluster cluster, RelTraitSet traitSet,
RelOptTable table, CassandraTable cassandraTable, RelDataType projectRowType) {
super(cluster, traitSet, table);
super(cluster, traitSet, ImmutableList.of(), table);
this.cassandraTable = cassandraTable;
this.projectRowType = projectRowType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public EnumerableAggregate(
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
throws InvalidRelException {
super(cluster, traitSet, input, groupSet, groupSets, aggCalls);
super(cluster, traitSet, ImmutableList.of(), input, groupSet, groupSets, aggCalls);
assert getConvention() instanceof EnumerableConvention;

for (AggregateCall aggCall : aggCalls) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected EnumerableBatchNestedLoopJoin(
Set<CorrelationId> variablesSet,
ImmutableBitSet requiredColumns,
JoinRelType joinType) {
super(cluster, traits, left, right, condition, variablesSet, joinType);
super(cluster, traits, ImmutableList.of(), left, right, condition, variablesSet, joinType);
this.requiredColumns = requiredColumns;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public EnumerableCalc(RelOptCluster cluster,
RelTraitSet traitSet,
RelNode input,
RexProgram program) {
super(cluster, traitSet, input, program);
super(cluster, traitSet, ImmutableList.of(), input, program);
assert getConvention() instanceof EnumerableConvention;
assert !program.containsAggs();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected EnumerableHashJoin(
super(
cluster,
traits,
ImmutableList.of(),
left,
right,
condition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class EnumerableMergeJoin extends Join implements EnumerableRel {
RexNode condition,
Set<CorrelationId> variablesSet,
JoinRelType joinType) {
super(cluster, traits, left, right, condition, variablesSet, joinType);
super(cluster, traits, ImmutableList.of(), left, right, condition, variablesSet, joinType);
final List<RelCollation> collations =
traits.getTraits(RelCollationTraitDef.INSTANCE);
assert collations == null || RelCollations.contains(collations, joinInfo.leftKeys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class EnumerableNestedLoopJoin extends Join implements EnumerableRel {
protected EnumerableNestedLoopJoin(RelOptCluster cluster, RelTraitSet traits,
RelNode left, RelNode right, RexNode condition,
Set<CorrelationId> variablesSet, JoinRelType joinType) {
super(cluster, traits, left, right, condition, variablesSet, joinType);
super(cluster, traits, ImmutableList.of(), left, right, condition, variablesSet, joinType);
}

@Deprecated // to be removed before 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.util.Util;

import com.google.common.collect.ImmutableList;

import java.util.List;

/** Implementation of {@link org.apache.calcite.rel.core.Project} in
Expand All @@ -49,7 +51,7 @@ public EnumerableProject(
RelNode input,
List<? extends RexNode> projects,
RelDataType rowType) {
super(cluster, traitSet, input, projects, rowType);
super(cluster, traitSet, ImmutableList.of(), input, projects, rowType);
assert getConvention() instanceof EnumerableConvention;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class EnumerableTableScan
* <p>Use {@link #create} unless you know what you are doing. */
public EnumerableTableScan(RelOptCluster cluster, RelTraitSet traitSet,
RelOptTable table, Class elementType) {
super(cluster, traitSet, table);
super(cluster, traitSet, ImmutableList.of(), table);
assert getConvention() instanceof EnumerableConvention;
this.elementType = elementType;
assert canHandle(table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public JdbcJoin(RelOptCluster cluster, RelTraitSet traitSet,
RelNode left, RelNode right, RexNode condition,
Set<CorrelationId> variablesSet, JoinRelType joinType)
throws InvalidRelException {
super(cluster, traitSet, left, right, condition, variablesSet, joinType);
super(cluster, traitSet, ImmutableList.of(), left, right, condition, variablesSet, joinType);
}

@Deprecated // to be removed before 2.0
Expand Down Expand Up @@ -557,7 +557,7 @@ public JdbcProject(
RelNode input,
List<? extends RexNode> projects,
RelDataType rowType) {
super(cluster, traitSet, input, projects, rowType);
super(cluster, traitSet, ImmutableList.of(), input, projects, rowType);
assert getConvention() instanceof JdbcConvention;
}

Expand Down Expand Up @@ -695,7 +695,7 @@ public JdbcAggregate(
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
throws InvalidRelException {
super(cluster, traitSet, input, groupSet, groupSets, aggCalls);
super(cluster, traitSet, ImmutableList.of(), input, groupSet, groupSets, aggCalls);
assert getConvention() instanceof JdbcConvention;
assert this.groupSets.size() == 1 : "Grouping sets not supported";
final SqlDialect dialect = ((JdbcConvention) getConvention()).dialect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected JdbcTableScan(
RelOptTable table,
JdbcTable jdbcTable,
JdbcConvention jdbcConvention) {
super(cluster, cluster.traitSetOf(jdbcConvention), table);
super(cluster, cluster.traitSetOf(jdbcConvention), ImmutableList.of(), table);
this.jdbcTable = Objects.requireNonNull(jdbcTable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static class BindableTableScan
BindableTableScan(RelOptCluster cluster, RelTraitSet traitSet,
RelOptTable table, ImmutableList<RexNode> filters,
ImmutableIntList projects) {
super(cluster, traitSet, table);
super(cluster, traitSet, ImmutableList.of(), table);
this.filters = Objects.requireNonNull(filters);
this.projects = Objects.requireNonNull(projects);
Preconditions.checkArgument(canHandle(table));
Expand Down Expand Up @@ -369,7 +369,7 @@ public RelNode convert(RelNode rel) {
public static class BindableProject extends Project implements BindableRel {
public BindableProject(RelOptCluster cluster, RelTraitSet traitSet,
RelNode input, List<? extends RexNode> projects, RelDataType rowType) {
super(cluster, traitSet, input, projects, rowType);
super(cluster, traitSet, ImmutableList.of(), input, projects, rowType);
assert getConvention() instanceof BindableConvention;
}

Expand Down Expand Up @@ -487,7 +487,8 @@ public static class BindableJoin extends Join implements BindableRel {
protected BindableJoin(RelOptCluster cluster, RelTraitSet traitSet,
RelNode left, RelNode right, RexNode condition,
Set<CorrelationId> variablesSet, JoinRelType joinType) {
super(cluster, traitSet, left, right, condition, variablesSet, joinType);
super(cluster, traitSet, ImmutableList.of(), left, right,
condition, variablesSet, joinType);
}

@Deprecated // to be removed before 2.0
Expand Down Expand Up @@ -630,7 +631,7 @@ public BindableAggregate(
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
throws InvalidRelException {
super(cluster, traitSet, input, groupSet, groupSets, aggCalls);
super(cluster, traitSet, ImmutableList.of(), input, groupSet, groupSets, aggCalls);
assert getConvention() instanceof BindableConvention;

for (AggregateCall aggCall : aggCalls) {
Expand Down
16 changes: 2 additions & 14 deletions core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,7 @@ protected Aggregate(
}
}

/**
* Create an Aggregate.
*
* @param cluster Cluster
* @param traitSet Trait set
* @param input Input relational expression
* @param groupSet Bit set of grouping fields
* @param groupSets List of all grouping sets; null for just {@code groupSet}
* @param aggCalls Collection of calls to aggregate functions
*/
@Deprecated // to be removed before 2.0
protected Aggregate(
RelOptCluster cluster,
RelTraitSet traitSet,
Expand All @@ -191,9 +182,6 @@ protected Aggregate(
this(cluster, traitSet, new ArrayList<>(), input, groupSet, groupSets, aggCalls);
}

/**
* Creates an Aggregate.
*/
@Deprecated // to be removed before 2.0
protected Aggregate(
RelOptCluster cluster,
Expand All @@ -203,7 +191,7 @@ protected Aggregate(
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls) {
this(cluster, traits, new ArrayList<>(), child, groupSet, groupSets, aggCalls);
this(cluster, traits, ImmutableList.of(), child, groupSet, groupSets, aggCalls);
checkIndicator(indicator);
}

Expand Down
14 changes: 3 additions & 11 deletions core/src/main/java/org/apache/calcite/rel/core/Calc.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import com.google.common.collect.ImmutableList;

import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -79,20 +78,13 @@ protected Calc(
assert isValid(Litmus.THROW, null);
}

/**
* Creates a Calc.
*
* @param cluster Cluster
* @param traits Traits
* @param child Input relation
* @param program Calc program
*/
@Deprecated // to be removed before 2.0
protected Calc(
RelOptCluster cluster,
RelTraitSet traits,
RelNode child,
RexProgram program) {
this(cluster, traits, Collections.emptyList(), child, program);
this(cluster, traits, ImmutableList.of(), child, program);
}

@Deprecated // to be removed before 2.0
Expand All @@ -102,7 +94,7 @@ protected Calc(
RelNode child,
RexProgram program,
List<RelCollation> collationList) {
this(cluster, traits, child, program);
this(cluster, traits, ImmutableList.of(), child, program);
Util.discard(collationList);
}

Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/org/apache/calcite/rel/core/EquiJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.util.ImmutableIntList;

import com.google.common.collect.ImmutableList;

import java.util.Objects;
import java.util.Set;

Expand Down Expand Up @@ -52,7 +54,7 @@ public abstract class EquiJoin extends Join {
public EquiJoin(RelOptCluster cluster, RelTraitSet traits, RelNode left,
RelNode right, RexNode condition, Set<CorrelationId> variablesSet,
JoinRelType joinType) {
super(cluster, traits, left, right, condition, variablesSet, joinType);
super(cluster, traits, ImmutableList.of(), left, right, condition, variablesSet, joinType);
this.leftKeys = Objects.requireNonNull(joinInfo.leftKeys);
this.rightKeys = Objects.requireNonNull(joinInfo.rightKeys);
assert joinInfo.isEqui() : "Create EquiJoin with non-equi join condition.";
Expand All @@ -64,7 +66,7 @@ public EquiJoin(RelOptCluster cluster, RelTraitSet traits, RelNode left,
RelNode right, RexNode condition, ImmutableIntList leftKeys,
ImmutableIntList rightKeys, Set<CorrelationId> variablesSet,
JoinRelType joinType) {
super(cluster, traits, left, right, condition, variablesSet, joinType);
super(cluster, traits, ImmutableList.of(), left, right, condition, variablesSet, joinType);
this.leftKeys = Objects.requireNonNull(leftKeys);
this.rightKeys = Objects.requireNonNull(rightKeys);
}
Expand Down
27 changes: 3 additions & 24 deletions core/src/main/java/org/apache/calcite/rel/core/Join.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -116,32 +115,12 @@ protected Join(
this.hints = ImmutableList.copyOf(hints);
}

/**
* Creates a Join.
*
* <p>Note: We plan to change the {@code variablesStopped} parameter to
* {@code Set&lt;CorrelationId&gt; variablesSet}
* {@link org.apache.calcite.util.Bug#upgrade(String) before version 2.0},
* because {@link #getVariablesSet()}
* is preferred over {@link #getVariablesStopped()}.
* This constructor is not deprecated, for now, because maintaining overloaded
* constructors in multiple sub-classes would be onerous.
*
* @param cluster Cluster
* @param traitSet Trait set
* @param left Left input
* @param right Right input
* @param condition Join condition
* @param joinType Join type
* @param variablesSet Set variables that are set by the
* LHS and used by the RHS and are not available to
* nodes above this Join in the tree
*/
@Deprecated // to be removed before 2.0
protected Join(
RelOptCluster cluster, RelTraitSet traitSet, RelNode left,
RelNode right, RexNode condition, Set<CorrelationId> variablesSet,
JoinRelType joinType) {
this(cluster, traitSet, new ArrayList<>(), left, right,
this(cluster, traitSet, ImmutableList.of(), left, right,
condition, variablesSet, joinType);
}

Expand All @@ -154,7 +133,7 @@ protected Join(
RexNode condition,
JoinRelType joinType,
Set<String> variablesStopped) {
this(cluster, traitSet, left, right, condition,
this(cluster, traitSet, ImmutableList.of(), left, right, condition,
CorrelationId.setOf(variablesStopped), joinType);
}

Expand Down
16 changes: 4 additions & 12 deletions core/src/main/java/org/apache/calcite/rel/core/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -91,24 +90,16 @@ protected Project(
assert isValid(Litmus.THROW, null);
}

/**
* Creates a Project.
*
* @param cluster Cluster that this relational expression belongs to
* @param traits Traits of this relational expression
* @param input Input relational expression
* @param projects List of expressions for the input columns
* @param rowType Output row type
*/
@Deprecated // to be removed before 2.0
protected Project(RelOptCluster cluster, RelTraitSet traits,
RelNode input, List<? extends RexNode> projects, RelDataType rowType) {
this(cluster, traits, new ArrayList<>(), input, projects, rowType);
this(cluster, traits, ImmutableList.of(), input, projects, rowType);
}

@Deprecated // to be removed before 2.0
protected Project(RelOptCluster cluster, RelTraitSet traitSet, RelNode input,
List<? extends RexNode> projects, RelDataType rowType, int flags) {
this(cluster, traitSet, input, projects, rowType);
this(cluster, traitSet, ImmutableList.of(), input, projects, rowType);
Util.discard(flags);
}

Expand All @@ -118,6 +109,7 @@ protected Project(RelOptCluster cluster, RelTraitSet traitSet, RelNode input,
protected Project(RelInput input) {
this(input.getCluster(),
input.getTraitSet(),
ImmutableList.of(),
input.getInput(),
input.getExpressionList("exprs"),
input.getRowType("exprs", "fields"));
Expand Down
Loading

0 comments on commit 5cfd8c3

Please sign in to comment.