Skip to content
Permalink
Browse files
IGNITE-16442 Upgrade to Apache Calcite 1.29.0
Signed-off-by: zstan <stanilovsky@gmail.com>
  • Loading branch information
zstan committed Feb 7, 2022
1 parent 66a6f39 commit c06f4c416c756cdbfd525745cdddf8c5c873d4cf
Showing 16 changed files with 190 additions and 111 deletions.
@@ -112,6 +112,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.immutables</groupId>
<artifactId>value-annotations</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.npathai</groupId>
<artifactId>hamcrest-optional</artifactId>
@@ -289,14 +289,29 @@
<artifactId>ignite-network-annotation-processor</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>${immutables.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- <compilerArgs>
<arg>-verbose</arg> <arg>-XprintRounds</arg> <arg>-XprintProcessorInfo</arg> <arg>-Xlint</arg> <arg>-J-verbose</arg>
</compilerArgs>-->
<annotationProcessorPaths>
<path>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-network-annotation-processor</artifactId>
<version>${project.version}</version>
</path>

<path>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>${immutables.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
@@ -76,7 +76,6 @@
import org.apache.calcite.rex.RexProgram;
import org.apache.calcite.rex.RexSlot;
import org.apache.calcite.sql.validate.SqlMonotonicity;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.ImmutableIntList;
import org.apache.calcite.util.Pair;
@@ -90,10 +89,8 @@
*/
@SuppressWarnings("unused") // actually all methods are used by runtime generated classes
public class IgniteMdCollation implements MetadataHandler<BuiltInMetadata.Collation> {

public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.COLLATIONS.method, new IgniteMdCollation());
ReflectiveRelMetadataProvider.reflectiveSource(new IgniteMdCollation(), BuiltInMetadata.Collation.Handler.class);

//~ Constructors -----------------------------------------------------------
private IgniteMdCollation() {
@@ -34,7 +34,6 @@
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.ignite.internal.sql.engine.rel.IgniteCorrelatedNestedLoopJoin;

/**
@@ -43,8 +42,8 @@
*/
@SuppressWarnings("unused") // actually all methods are used by runtime generated classes
public class IgniteMdCumulativeCost implements MetadataHandler<BuiltInMetadata.CumulativeCost> {
public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.CUMULATIVE_COST.method, new IgniteMdCumulativeCost());
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(new IgniteMdCumulativeCost(), BuiltInMetadata.CumulativeCost.Handler.class);

/** {@inheritDoc} */
@Override
@@ -23,13 +23,13 @@
import java.util.ArrayList;
import java.util.List;
import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.RelRule;
import org.apache.calcite.rel.core.Aggregate;
import org.apache.calcite.rel.logical.LogicalAggregate;
import org.apache.calcite.rel.logical.LogicalFilter;
import org.apache.calcite.rel.logical.LogicalJoin;
import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.logical.LogicalSort;
import org.apache.calcite.rel.rules.AggregateExpandDistinctAggregatesRule;
import org.apache.calcite.rel.rules.AggregateMergeRule;
import org.apache.calcite.rel.rules.CoreRules;
import org.apache.calcite.rel.rules.FilterJoinRule.FilterIntoJoinRule;
@@ -132,11 +132,11 @@ public Program getProgram(PlanningContext ctx) {
JoinPushExpressionsRule.Config.DEFAULT
.withOperandFor(LogicalJoin.class).toRule(),

JoinConditionPushRule.Config.DEFAULT
JoinConditionPushRule.JoinConditionPushRuleConfig.DEFAULT
.withOperandSupplier(b -> b.operand(LogicalJoin.class)
.anyInputs()).toRule(),

FilterIntoJoinRule.Config.DEFAULT
FilterIntoJoinRule.FilterIntoJoinRuleConfig.DEFAULT
.withOperandSupplier(b0 ->
b0.operand(LogicalFilter.class).oneInput(b1 ->
b1.operand(LogicalJoin.class).anyInputs())).toRule(),
@@ -165,7 +165,7 @@ public Program getProgram(PlanningContext ctx) {
.predicate(Aggregate::isSimple)
.anyInputs())).toRule(),

AggregateExpandDistinctAggregatesRule.Config.JOIN.toRule(),
CoreRules.AGGREGATE_EXPAND_DISTINCT_AGGREGATES_TO_JOIN,

SortRemoveRule.Config.DEFAULT
.withOperandSupplier(b ->
@@ -183,11 +183,9 @@ public Program getProgram(PlanningContext ctx) {
// Useful of this rule is not clear now.
// CoreRules.AGGREGATE_REDUCE_FUNCTIONS,

PruneEmptyRules.SortFetchZeroRuleConfig.EMPTY
((RelRule<?>) PruneEmptyRules.SORT_FETCH_ZERO_INSTANCE).config
.withOperandSupplier(b ->
b.operand(LogicalSort.class).anyInputs())
.withDescription("PruneSortLimit0")
.as(PruneEmptyRules.SortFetchZeroRuleConfig.class)
.toRule(),

ExposeIndexRule.INSTANCE,
@@ -30,7 +30,6 @@
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.core.Spool;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexNode;
@@ -41,10 +40,12 @@
import org.apache.ignite.internal.sql.engine.trait.CorrelationTrait;
import org.apache.ignite.internal.sql.engine.trait.TraitUtils;
import org.apache.ignite.internal.sql.engine.util.RexUtils;
import org.immutables.value.Value;

/**
* Rule that pushes filter into the spool.
*/
@Value.Enclosing
public class FilterSpoolMergeToHashIndexSpoolRule extends RelRule<FilterSpoolMergeToHashIndexSpoolRule.Config> {
/** Instance. */
public static final RelOptRule INSTANCE = Config.DEFAULT.toRule();
@@ -110,11 +111,10 @@ public void onMatch(RelOptRuleCall call) {
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@SuppressWarnings("ClassNameSameAsAncestorName")
@Value.Immutable
public interface Config extends RelRule.Config {
Config DEFAULT = RelRule.Config.EMPTY
.withRelBuilderFactory(RelFactories.LOGICAL_BUILDER)
Config DEFAULT = ImmutableFilterSpoolMergeToHashIndexSpoolRule.Config.of()
.withDescription("FilterSpoolMergeToHashIndexSpoolRule")
.as(FilterSpoolMergeToHashIndexSpoolRule.Config.class)
.withOperandFor(IgniteFilter.class, IgniteTableSpool.class);

/** Defines an operand tree for the given classes. */
@@ -27,7 +27,6 @@
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.core.Spool;
import org.apache.ignite.internal.sql.engine.rel.IgniteFilter;
import org.apache.ignite.internal.sql.engine.rel.IgniteSortedIndexSpool;
@@ -36,10 +35,12 @@
import org.apache.ignite.internal.sql.engine.trait.TraitUtils;
import org.apache.ignite.internal.sql.engine.util.IndexConditions;
import org.apache.ignite.internal.sql.engine.util.RexUtils;
import org.immutables.value.Value;

/**
* Rule that pushes filter into the spool.
*/
@Value.Enclosing
public class FilterSpoolMergeToSortedIndexSpoolRule extends RelRule<FilterSpoolMergeToSortedIndexSpoolRule.Config> {
/** Instance. */
public static final RelOptRule INSTANCE = Config.DEFAULT.toRule();
@@ -96,12 +97,10 @@ public void onMatch(RelOptRuleCall call) {
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@SuppressWarnings("ClassNameSameAsAncestorName")
@Value.Immutable
public interface Config extends RelRule.Config {

Config DEFAULT = RelRule.Config.EMPTY
.withRelBuilderFactory(RelFactories.LOGICAL_BUILDER)
Config DEFAULT = ImmutableFilterSpoolMergeToSortedIndexSpoolRule.Config.of()
.withDescription("FilterSpoolMergeToSortedIndexSpoolRule")
.as(FilterSpoolMergeToSortedIndexSpoolRule.Config.class)
.withOperandFor(IgniteFilter.class, IgniteTableSpool.class);

/** Defines an operand tree for the given classes. */
@@ -29,25 +29,26 @@
import org.apache.ignite.internal.sql.engine.rel.IgniteLimit;
import org.apache.ignite.internal.sql.engine.rel.IgniteSort;
import org.apache.ignite.internal.sql.engine.trait.IgniteDistributions;
import org.immutables.value.Value;

/**
* Converter rule for sort operator.
*/
@Value.Enclosing
public class SortConverterRule extends RelRule<SortConverterRule.Config> {
public static final RelOptRule INSTANCE = SortConverterRule.Config.DEFAULT
.as(SortConverterRule.Config.class).toRule();
public static final RelOptRule INSTANCE = SortConverterRule.Config.DEFAULT.toRule();

/** Creates a LimitConverterRule. */
protected SortConverterRule(SortConverterRule.Config config) {
super(config);
}

/** Rule configuration. */
@Value.Immutable
public interface Config extends RelRule.Config {
SortConverterRule.Config DEFAULT = EMPTY
SortConverterRule.Config DEFAULT = ImmutableSortConverterRule.Config.of()
.withOperandSupplier(b ->
b.operand(LogicalSort.class).anyInputs())
.as(SortConverterRule.Config.class);
b.operand(LogicalSort.class).anyInputs());

/** {@inheritDoc} */
@Override
@@ -24,18 +24,19 @@
import org.apache.calcite.plan.RelRule;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.logical.LogicalUnion;
import org.apache.calcite.tools.RelBuilder;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.ignite.internal.sql.engine.rel.IgniteConvention;
import org.apache.ignite.internal.sql.engine.rel.IgniteUnionAll;
import org.apache.ignite.internal.sql.engine.util.Commons;
import org.immutables.value.Value;

/**
* UnionConverterRule.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@Value.Enclosing
public class UnionConverterRule extends RelRule<UnionConverterRule.Config> {
/** Instance. */
public static final RelOptRule INSTANCE = Config.DEFAULT.toRule();
@@ -72,11 +73,10 @@ public void onMatch(RelOptRuleCall call) {
* Config interface.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@Value.Immutable
public interface Config extends RelRule.Config {
UnionConverterRule.Config DEFAULT = RelRule.Config.EMPTY
.withRelBuilderFactory(RelFactories.LOGICAL_BUILDER)
UnionConverterRule.Config DEFAULT = ImmutableUnionConverterRule.Config.of()
.withDescription("UnionConverterRule")
.as(UnionConverterRule.Config.class)
.withOperandFor(LogicalUnion.class);

/** Defines an operand tree for the given classes. */
@@ -27,17 +27,18 @@
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.plan.RelRule;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalIndexScan;
import org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalTableScan;
import org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable;
import org.immutables.value.Value;

/**
* ExposeIndexRule.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@Value.Enclosing
public class ExposeIndexRule extends RelRule<ExposeIndexRule.Config> {
public static final RelOptRule INSTANCE = Config.DEFAULT.toRule();

@@ -82,14 +83,13 @@ public void onMatch(RelOptRuleCall call) {
* Rule's configuration.
*/
@SuppressWarnings("ClassNameSameAsAncestorName")
@Value.Immutable
public interface Config extends RelRule.Config {
Config DEFAULT = EMPTY
.withRelBuilderFactory(RelFactories.LOGICAL_BUILDER)
Config DEFAULT = ImmutableExposeIndexRule.Config.of()
.withOperandSupplier(b ->
b.operand(IgniteLogicalTableScan.class)
.predicate(ExposeIndexRule::preMatch)
.anyInputs())
.as(Config.class);
b.operand(IgniteLogicalTableScan.class)
.predicate(ExposeIndexRule::preMatch)
.anyInputs());

/** {@inheritDoc} */
@Override default ExposeIndexRule toRule() {

0 comments on commit c06f4c4

Please sign in to comment.