You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by da...@apache.org on 2019/07/01 08:52:52 UTC

[calcite] branch master updated: [CALCITE-3126] Remove deprecated SemiJoin usage completely

This is an automated email from the ASF dual-hosted git repository.

danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new 79a4ec6  [CALCITE-3126] Remove deprecated SemiJoin usage completely
79a4ec6 is described below

commit 79a4ec63adfa83c6920b9ece5042f65a322ff80f
Author: yuzhao.cyz <yu...@alibaba-inc.com>
AuthorDate: Mon Jul 1 11:39:06 2019 +0800

    [CALCITE-3126] Remove deprecated SemiJoin usage completely
---
 .../adapter/enumerable/EnumerableRules.java        |   8 --
 .../adapter/enumerable/EnumerableSemiJoin.java     | 152 ---------------------
 .../adapter/enumerable/EnumerableSemiJoinRule.java |  56 --------
 .../org/apache/calcite/rel/core/RelFactories.java  |   8 +-
 .../java/org/apache/calcite/rel/core/SemiJoin.java | 132 ------------------
 .../calcite/rel/metadata/RelMdCollation.java       |   9 --
 .../rel/metadata/RelMdColumnUniqueness.java        |   9 --
 .../rel/metadata/RelMdDistinctRowCount.java        |   7 -
 .../calcite/rel/metadata/RelMdNodeTypes.java       |   7 -
 .../calcite/rel/metadata/RelMdPopulationSize.java  |   6 -
 .../apache/calcite/rel/metadata/RelMdRowCount.java |  14 --
 .../org/apache/calcite/rel/metadata/RelMdSize.java |   6 -
 .../calcite/rel/metadata/RelMdUniqueKeys.java      |   8 --
 .../org/apache/calcite/rel/metadata/RelMdUtil.java |  16 ---
 .../apache/calcite/rel/mutable/MutableRelType.java |   1 -
 .../apache/calcite/rel/mutable/MutableRels.java    |  19 ---
 .../calcite/rel/mutable/MutableSemiJoin.java       |  88 ------------
 .../calcite/rel/rel2sql/RelToSqlConverter.java     |   9 +-
 .../calcite/rel/rules/JoinToCorrelateRule.java     |  12 --
 .../java/org/apache/calcite/sql/SemiJoinType.java  |  12 +-
 .../java/org/apache/calcite/tools/Programs.java    |   4 -
 21 files changed, 14 insertions(+), 569 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRules.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRules.java
index f3ca806..fabf49d 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRules.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRules.java
@@ -44,13 +44,6 @@ public class EnumerableRules {
   public static final RelOptRule ENUMERABLE_MERGE_JOIN_RULE =
       new EnumerableMergeJoinRule();
 
-  /** @deprecated To be removed along with
-   * {@link org.apache.calcite.rel.core.SemiJoin};
-   * use {@link #ENUMERABLE_JOIN_RULE} instead. */
-  @Deprecated // to be removed before 1.21
-  public static final RelOptRule ENUMERABLE_SEMI_JOIN_RULE =
-      new EnumerableSemiJoinRule();
-
   public static final RelOptRule ENUMERABLE_CORRELATE_RULE =
       new EnumerableCorrelateRule(RelFactories.LOGICAL_BUILDER);
 
@@ -117,7 +110,6 @@ public class EnumerableRules {
   public static final List<RelOptRule> ENUMERABLE_RULES = ImmutableList.of(
       EnumerableRules.ENUMERABLE_JOIN_RULE,
       EnumerableRules.ENUMERABLE_MERGE_JOIN_RULE,
-      EnumerableRules.ENUMERABLE_SEMI_JOIN_RULE,
       EnumerableRules.ENUMERABLE_CORRELATE_RULE,
       EnumerableRules.ENUMERABLE_PROJECT_RULE,
       EnumerableRules.ENUMERABLE_FILTER_RULE,
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSemiJoin.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSemiJoin.java
deleted file mode 100644
index bf13091..0000000
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSemiJoin.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.adapter.enumerable;
-
-import org.apache.calcite.linq4j.tree.BlockBuilder;
-import org.apache.calcite.linq4j.tree.Expression;
-import org.apache.calcite.linq4j.tree.Expressions;
-import org.apache.calcite.plan.RelOptCluster;
-import org.apache.calcite.plan.RelOptCost;
-import org.apache.calcite.plan.RelOptPlanner;
-import org.apache.calcite.plan.RelTraitSet;
-import org.apache.calcite.rel.InvalidRelException;
-import org.apache.calcite.rel.RelCollationTraitDef;
-import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.core.JoinInfo;
-import org.apache.calcite.rel.core.JoinRelType;
-import org.apache.calcite.rel.metadata.RelMdCollation;
-import org.apache.calcite.rel.metadata.RelMetadataQuery;
-import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.util.BuiltInMethod;
-import org.apache.calcite.util.ImmutableIntList;
-import org.apache.calcite.util.Util;
-
-/** Implementation of {@link org.apache.calcite.rel.core.SemiJoin} in
- * {@link org.apache.calcite.adapter.enumerable.EnumerableConvention enumerable calling convention}.
- *
- * @deprecated This class is deprecated along with
- * {@link org.apache.calcite.rel.core.SemiJoin};
- * the function is merged into {@link EnumerableHashJoin};
- * see {@link EnumerableJoinRule} for details.
- */
-@Deprecated // to be removed before 1.21
-public class EnumerableSemiJoin extends org.apache.calcite.rel.core.SemiJoin
-    implements EnumerableRel {
-  /** Creates an EnumerableSemiJoin.
-   *
-   * <p>Use {@link #create} unless you know what you're doing. */
-  EnumerableSemiJoin(
-      RelOptCluster cluster,
-      RelTraitSet traits,
-      RelNode left,
-      RelNode right,
-      RexNode condition,
-      ImmutableIntList leftKeys,
-      ImmutableIntList rightKeys)
-      throws InvalidRelException {
-    super(cluster, traits, left, right, condition, leftKeys, rightKeys);
-  }
-
-  /** Creates an EnumerableSemiJoin. */
-  public static EnumerableSemiJoin create(RelNode left, RelNode right, RexNode condition,
-      ImmutableIntList leftKeys, ImmutableIntList rightKeys) {
-    final RelOptCluster cluster = left.getCluster();
-    final RelMetadataQuery mq = cluster.getMetadataQuery();
-    final RelTraitSet traitSet =
-        cluster.traitSetOf(EnumerableConvention.INSTANCE)
-            .replaceIfs(RelCollationTraitDef.INSTANCE,
-                () -> RelMdCollation.enumerableSemiJoin(mq, left, right));
-    try {
-      return new EnumerableSemiJoin(
-          cluster,
-          traitSet,
-          left,
-          right,
-          condition,
-          leftKeys,
-          rightKeys);
-    } catch (InvalidRelException e) {
-      // Semantic error not possible. Must be a bug. Convert to
-      // internal error.
-      throw new AssertionError(e);
-    }
-  }
-
-  @Override public EnumerableSemiJoin copy(RelTraitSet traitSet,
-      RexNode condition, RelNode left, RelNode right, JoinRelType joinType,
-      boolean semiJoinDone) {
-    assert joinType == JoinRelType.INNER;
-    final JoinInfo joinInfo = JoinInfo.of(left, right, condition);
-    assert joinInfo.isEqui();
-    try {
-      return new EnumerableSemiJoin(getCluster(), traitSet, left, right,
-          condition, joinInfo.leftKeys, joinInfo.rightKeys);
-    } catch (InvalidRelException e) {
-      // Semantic error not possible. Must be a bug. Convert to
-      // internal error.
-      throw new AssertionError(e);
-    }
-  }
-
-  @Override public RelOptCost computeSelfCost(RelOptPlanner planner,
-      RelMetadataQuery mq) {
-    double rowCount = mq.getRowCount(this);
-
-    // Right-hand input is the "build", and hopefully small, input.
-    final double rightRowCount = right.estimateRowCount(mq);
-    final double leftRowCount = left.estimateRowCount(mq);
-    if (Double.isInfinite(leftRowCount)) {
-      rowCount = leftRowCount;
-    } else {
-      rowCount += Util.nLogN(leftRowCount);
-    }
-    if (Double.isInfinite(rightRowCount)) {
-      rowCount = rightRowCount;
-    } else {
-      rowCount += rightRowCount;
-    }
-    return planner.getCostFactory().makeCost(rowCount, 0, 0).multiplyBy(.01d);
-  }
-
-  public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
-    BlockBuilder builder = new BlockBuilder();
-    final Result leftResult =
-        implementor.visitChild(this, 0, (EnumerableRel) left, pref);
-    Expression leftExpression =
-        builder.append(
-            "left", leftResult.block);
-    final Result rightResult =
-        implementor.visitChild(this, 1, (EnumerableRel) right, pref);
-    Expression rightExpression =
-        builder.append(
-            "right", rightResult.block);
-    final PhysType physType = leftResult.physType;
-    return implementor.result(
-        physType,
-        builder.append(
-            Expressions.call(
-                BuiltInMethod.SEMI_JOIN.method,
-                Expressions.list(
-                    leftExpression,
-                    rightExpression,
-                    leftResult.physType.generateAccessor(leftKeys),
-                    rightResult.physType.generateAccessor(rightKeys))))
-            .toBlock());
-  }
-}
-
-// End EnumerableSemiJoin.java
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSemiJoinRule.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSemiJoinRule.java
deleted file mode 100644
index cd54be4..0000000
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSemiJoinRule.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.adapter.enumerable;
-
-import org.apache.calcite.plan.Convention;
-import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.convert.ConverterRule;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** Planner rule that converts a
- * {@link org.apache.calcite.rel.core.SemiJoin} relational expression
- * {@link org.apache.calcite.adapter.enumerable.EnumerableConvention enumerable calling convention}.
- *
- * @deprecated Use {@link EnumerableJoinRule} instead.
- */
-@Deprecated // to be removed before 1.21
-class EnumerableSemiJoinRule extends ConverterRule {
-  EnumerableSemiJoinRule() {
-    super(org.apache.calcite.rel.core.SemiJoin.class, Convention.NONE,
-        EnumerableConvention.INSTANCE, "EnumerableSemiJoinRule");
-  }
-
-  @Override public RelNode convert(RelNode rel) {
-    final org.apache.calcite.rel.core.SemiJoin semiJoin =
-        (org.apache.calcite.rel.core.SemiJoin) rel;
-    final List<RelNode> newInputs = new ArrayList<>();
-    for (RelNode input : semiJoin.getInputs()) {
-      if (!(input.getConvention() instanceof EnumerableConvention)) {
-        input =
-            convert(input,
-                input.getTraitSet().replace(EnumerableConvention.INSTANCE));
-      }
-      newInputs.add(input);
-    }
-    return EnumerableSemiJoin.create(newInputs.get(0), newInputs.get(1),
-        semiJoin.getCondition(), semiJoin.leftKeys, semiJoin.rightKeys);
-  }
-}
-
-// End EnumerableSemiJoinRule.java
diff --git a/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java b/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java
index 6e9471e..728bc20 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java
@@ -54,6 +54,7 @@ import org.apache.calcite.tools.RelBuilderFactory;
 import org.apache.calcite.util.ImmutableBitSet;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 
 import java.lang.reflect.Type;
 import java.util.List;
@@ -413,7 +414,7 @@ public class RelFactories {
 
   /**
    * Implementation of {@link SemiJoinFactory} that returns a vanilla
-   * {@link SemiJoin}.
+   * {@link Join} with join type as {@link JoinRelType#SEMI}.
    *
    * @deprecated Use {@link JoinFactoryImpl} instead.
    */
@@ -421,9 +422,8 @@ public class RelFactories {
   private static class SemiJoinFactoryImpl implements SemiJoinFactory {
     public RelNode createSemiJoin(RelNode left, RelNode right,
         RexNode condition) {
-      final JoinInfo joinInfo = JoinInfo.of(left, right, condition);
-      return SemiJoin.create(left, right,
-        condition, joinInfo.leftKeys, joinInfo.rightKeys);
+      return LogicalJoin.create(left, right, condition, ImmutableSet.of(), JoinRelType.SEMI,
+          false, ImmutableList.of());
     }
   }
 
diff --git a/core/src/main/java/org/apache/calcite/rel/core/SemiJoin.java b/core/src/main/java/org/apache/calcite/rel/core/SemiJoin.java
deleted file mode 100644
index d1afa8d..0000000
--- a/core/src/main/java/org/apache/calcite/rel/core/SemiJoin.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.rel.core;
-
-import org.apache.calcite.plan.Convention;
-import org.apache.calcite.plan.RelOptCluster;
-import org.apache.calcite.plan.RelOptCost;
-import org.apache.calcite.plan.RelOptPlanner;
-import org.apache.calcite.plan.RelTraitSet;
-import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.metadata.RelMdUtil;
-import org.apache.calcite.rel.metadata.RelMetadataQuery;
-import org.apache.calcite.rel.type.RelDataType;
-import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.sql.validate.SqlValidatorUtil;
-import org.apache.calcite.util.ImmutableIntList;
-import org.apache.calcite.util.Util;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Relational expression that joins two relational expressions according to some
- * condition, but outputs only columns from the left input, and eliminates
- * duplicates.
- *
- * <p>The effect is something like the SQL {@code IN} operator.
- *
- * @deprecated This class is deprecated, please use
- * {@link org.apache.calcite.rel.logical.LogicalJoin} with join type {@link JoinRelType#SEMI}
- * instead.
- */
-@Deprecated // to be removed before 2.0
-public class SemiJoin extends EquiJoin {
-  //~ Constructors -----------------------------------------------------------
-
-  /**
-   * Creates a SemiJoin.
-   *
-   * <p>Use {@link #create} unless you know what you're doing.
-   *
-   * @param cluster   cluster that join belongs to
-   * @param traitSet  Trait set
-   * @param left      left join input
-   * @param right     right join input
-   * @param condition join condition
-   * @param leftKeys  left keys of the semijoin
-   * @param rightKeys right keys of the semijoin
-   */
-  public SemiJoin(
-      RelOptCluster cluster,
-      RelTraitSet traitSet,
-      RelNode left,
-      RelNode right,
-      RexNode condition,
-      ImmutableIntList leftKeys,
-      ImmutableIntList rightKeys) {
-    super(
-        cluster,
-        traitSet,
-        left,
-        right,
-        condition,
-        leftKeys,
-        rightKeys,
-        ImmutableSet.of(),
-        JoinRelType.INNER);
-  }
-
-  /** Creates a SemiJoin. */
-  public static SemiJoin create(RelNode left, RelNode right, RexNode condition,
-      ImmutableIntList leftKeys, ImmutableIntList rightKeys) {
-    final RelOptCluster cluster = left.getCluster();
-    return new SemiJoin(cluster, cluster.traitSetOf(Convention.NONE), left,
-        right, condition, leftKeys, rightKeys);
-  }
-
-  //~ Methods ----------------------------------------------------------------
-
-  @Override public SemiJoin copy(RelTraitSet traitSet, RexNode condition,
-      RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone) {
-    assert joinType == JoinRelType.INNER;
-    final JoinInfo joinInfo = JoinInfo.of(left, right, condition);
-    assert joinInfo.isEqui();
-    return new SemiJoin(getCluster(), traitSet, left, right, condition,
-        joinInfo.leftKeys, joinInfo.rightKeys);
-  }
-
-  @Override public RelOptCost computeSelfCost(RelOptPlanner planner,
-      RelMetadataQuery mq) {
-    // REVIEW jvs 9-Apr-2006:  Just for now...
-    return planner.getCostFactory().makeTinyCost();
-  }
-
-  @Override public double estimateRowCount(RelMetadataQuery mq) {
-    return Util.first(
-        RelMdUtil.getSemiJoinRowCount(mq, left, right, joinType, condition),
-        1D);
-  }
-
-  /**
-   * {@inheritDoc}
-   *
-   * <p>In the case of semi-join, the row type consists of columns from left
-   * input only.
-   */
-  @Override public RelDataType deriveRowType() {
-    return SqlValidatorUtil.deriveJoinRowType(
-        left.getRowType(),
-        null,
-        JoinRelType.INNER,
-        getCluster().getTypeFactory(),
-        null,
-        ImmutableList.of());
-  }
-}
-
-// End SemiJoin.java
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdCollation.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdCollation.java
index b669229..2e3d317 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdCollation.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdCollation.java
@@ -97,7 +97,6 @@ public class RelMdCollation
    * {@link org.apache.calcite.rel.core.Intersect},
    * {@link org.apache.calcite.rel.core.Minus},
    * {@link org.apache.calcite.rel.core.Join},
-   * {@link org.apache.calcite.rel.core.SemiJoin},
    * {@link org.apache.calcite.rel.core.Correlate}
    * do not in general return sorted results
    * (but implementations using particular algorithms may).
@@ -156,14 +155,6 @@ public class RelMdCollation
             join.getJoinType()));
   }
 
-  @Deprecated // to be removed before 1.21
-  public ImmutableList<RelCollation> collations(
-      org.apache.calcite.adapter.enumerable.EnumerableSemiJoin join,
-      RelMetadataQuery mq) {
-    return ImmutableList.copyOf(
-        RelMdCollation.enumerableSemiJoin(mq, join.getLeft(), join.getRight()));
-  }
-
   public ImmutableList<RelCollation> collations(Sort sort,
       RelMetadataQuery mq) {
     return ImmutableList.copyOf(
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
index 0ae9684..dce0564 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
@@ -312,15 +312,6 @@ public class RelMdColumnUniqueness
     throw new AssertionError();
   }
 
-  @Deprecated // to be removed before 1.21
-  public Boolean areColumnsUnique(
-      org.apache.calcite.rel.core.SemiJoin rel, RelMetadataQuery mq,
-      ImmutableBitSet columns, boolean ignoreNulls) {
-    // only return the unique keys from the LHS since a semijoin only
-    // returns the LHS
-    return mq.areColumnsUnique(rel.getLeft(), columns, ignoreNulls);
-  }
-
   public Boolean areColumnsUnique(Aggregate rel, RelMetadataQuery mq,
       ImmutableBitSet columns, boolean ignoreNulls) {
     // group by keys form a unique key
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
index 688eb2a..0cca9a4 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
@@ -142,13 +142,6 @@ public class RelMdDistinctRowCount
         groupKey, predicate, false);
   }
 
-  @Deprecated // to be removed before 1.21
-  public Double getDistinctRowCount(
-      org.apache.calcite.rel.core.SemiJoin rel, RelMetadataQuery mq,
-      ImmutableBitSet groupKey, RexNode predicate) {
-    return RelMdUtil.getSemiJoinDistinctRowCount(rel, mq, groupKey, predicate);
-  }
-
   public Double getDistinctRowCount(Aggregate rel, RelMetadataQuery mq,
       ImmutableBitSet groupKey, RexNode predicate) {
     if (predicate == null || predicate.isAlwaysTrue()) {
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdNodeTypes.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdNodeTypes.java
index c9052a1..22737b6 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdNodeTypes.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdNodeTypes.java
@@ -113,13 +113,6 @@ public class RelMdNodeTypes
     return getNodeTypes(rel, Join.class, mq);
   }
 
-  @Deprecated // to be removed before 1.21
-  public Multimap<Class<? extends RelNode>, RelNode> getNodeTypes(
-      org.apache.calcite.rel.core.SemiJoin rel,
-      RelMetadataQuery mq) {
-    return getNodeTypes(rel, org.apache.calcite.rel.core.SemiJoin.class, mq);
-  }
-
   public Multimap<Class<? extends RelNode>, RelNode> getNodeTypes(Aggregate rel,
       RelMetadataQuery mq) {
     return getNodeTypes(rel, Aggregate.class, mq);
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
index f1adadf..8e21963 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
@@ -84,12 +84,6 @@ public class RelMdPopulationSize
     return RelMdUtil.getJoinPopulationSize(mq, rel, groupKey);
   }
 
-  @Deprecated // to be removed before 1.21
-  public Double getPopulationSize(org.apache.calcite.rel.core.SemiJoin rel,
-      RelMetadataQuery mq, ImmutableBitSet groupKey) {
-    return mq.getPopulationSize(rel.getLeft(), groupKey);
-  }
-
   public Double getPopulationSize(Aggregate rel, RelMetadataQuery mq,
       ImmutableBitSet groupKey) {
     ImmutableBitSet.Builder childKey = ImmutableBitSet.builder();
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
index be01204..0550e61 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
@@ -33,7 +33,6 @@ import org.apache.calcite.rel.core.Union;
 import org.apache.calcite.rel.core.Values;
 import org.apache.calcite.rex.RexDynamicParam;
 import org.apache.calcite.rex.RexLiteral;
-import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.util.Bug;
 import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableBitSet;
@@ -187,19 +186,6 @@ public class RelMdRowCount
     return RelMdUtil.getJoinRowCount(mq, rel, rel.getCondition());
   }
 
-  @Deprecated // to be removed before 1.21
-  public Double getRowCount(org.apache.calcite.rel.core.SemiJoin rel,
-      RelMetadataQuery mq) {
-    // create a RexNode representing the selectivity of the
-    // semijoin filter and pass it to getSelectivity
-    RexNode semiJoinSelectivity =
-        RelMdUtil.makeSemiJoinSelectivityRexNode(mq, rel);
-
-    return NumberUtil.multiply(
-        mq.getSelectivity(rel.getLeft(), semiJoinSelectivity),
-        mq.getRowCount(rel.getLeft()));
-  }
-
   public Double getRowCount(Aggregate rel, RelMetadataQuery mq) {
     ImmutableBitSet groupKey = rel.getGroupSet();
 
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSize.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSize.java
index 16637a2..3d67ee9 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSize.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSize.java
@@ -176,12 +176,6 @@ public class RelMdSize implements MetadataHandler<BuiltInMetadata.Size> {
     return list.build();
   }
 
-  @Deprecated // to be removed before 1.21
-  public List<Double> averageColumnSizes(
-      org.apache.calcite.rel.core.SemiJoin rel, RelMetadataQuery mq) {
-    return averageJoinColumnSizes(rel, mq);
-  }
-
   public List<Double> averageColumnSizes(Join rel, RelMetadataQuery mq) {
     return averageJoinColumnSizes(rel, mq);
   }
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
index 6c13b0b..d33873e 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
@@ -205,14 +205,6 @@ public class RelMdUniqueKeys
     return retSet;
   }
 
-  @Deprecated // to be removed before 1.21
-  public Set<ImmutableBitSet> getUniqueKeys(org.apache.calcite.rel.core.SemiJoin rel,
-      RelMetadataQuery mq, boolean ignoreNulls) {
-    // only return the unique keys from the LHS since a semijoin only
-    // returns the LHS
-    return mq.getUniqueKeys(rel.getLeft(), ignoreNulls);
-  }
-
   public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
       boolean ignoreNulls) {
     // group by keys form a unique key
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
index e64bf4f..b53bd9a 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
@@ -110,22 +110,6 @@ public class RelMdUtil {
    * table/columns and the number of distinct values in the fact table
    * columns.
    *
-   * @param rel semijoin rel
-   * @return calculated selectivity
-   */
-  @Deprecated // to be removed before 1.21
-  public static double computeSemiJoinSelectivity(RelMetadataQuery mq,
-      org.apache.calcite.rel.core.SemiJoin rel) {
-    return computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(),
-        rel.getLeftKeys(), rel.getRightKeys());
-  }
-
-  /**
-   * Computes the selectivity of a semijoin filter if it is applied on a fact
-   * table. The computation is based on the selectivity of the dimension
-   * table/columns and the number of distinct values in the fact table
-   * columns.
-   *
    * @param factRel fact table participating in the semijoin
    * @param dimRel  dimension table participating in the semijoin
    * @param rel     semijoin rel
diff --git a/core/src/main/java/org/apache/calcite/rel/mutable/MutableRelType.java b/core/src/main/java/org/apache/calcite/rel/mutable/MutableRelType.java
index c42c331..3fe6123 100644
--- a/core/src/main/java/org/apache/calcite/rel/mutable/MutableRelType.java
+++ b/core/src/main/java/org/apache/calcite/rel/mutable/MutableRelType.java
@@ -29,7 +29,6 @@ enum MutableRelType {
   MINUS,
   PROJECT,
   SAMPLE,
-  SEMIJOIN,
   SORT,
   TABLE_FUNCTION_SCAN,
   TABLE_MODIFY,
diff --git a/core/src/main/java/org/apache/calcite/rel/mutable/MutableRels.java b/core/src/main/java/org/apache/calcite/rel/mutable/MutableRels.java
index 92f8958..90c9678 100644
--- a/core/src/main/java/org/apache/calcite/rel/mutable/MutableRels.java
+++ b/core/src/main/java/org/apache/calcite/rel/mutable/MutableRels.java
@@ -251,12 +251,6 @@ public abstract class MutableRels {
       relBuilder.push(fromMutable(join.getRight(), relBuilder));
       relBuilder.join(join.joinType, join.condition, join.variablesSet);
       return relBuilder.build();
-    case SEMIJOIN:
-      final MutableSemiJoin semiJoin = (MutableSemiJoin) node;
-      relBuilder.push(fromMutable(semiJoin.getLeft(), relBuilder));
-      relBuilder.push(fromMutable(semiJoin.getRight(), relBuilder));
-      relBuilder.semiJoin(semiJoin.condition);
-      return relBuilder.build();
     case CORRELATE:
       final MutableCorrelate correlate = (MutableCorrelate) node;
       return LogicalCorrelate.create(fromMutable(correlate.getLeft(), relBuilder),
@@ -288,7 +282,6 @@ public abstract class MutableRels {
         mutableRel -> fromMutable(mutableRel, relBuilder));
   }
 
-  @SuppressWarnings("deprecation") // directive to be removed before 1.21
   public static MutableRel toMutable(RelNode rel) {
     if (rel instanceof HepRelVertex) {
       return toMutable(((HepRelVertex) rel).getCurrentRel());
@@ -372,18 +365,6 @@ public abstract class MutableRels {
     }
     // It is necessary that SemiJoin is placed in front of Join here, since SemiJoin
     // is a sub-class of Join.
-    //
-    // NOTE: SemiJoin is deprecated and wil be removed before 1.21; when you
-    // remove the following lines, also remove the 'SuppressWarnings'
-    // directive at the top of this method.
-    if (rel instanceof org.apache.calcite.rel.core.SemiJoin) {
-      final org.apache.calcite.rel.core.SemiJoin semiJoin =
-          (org.apache.calcite.rel.core.SemiJoin) rel;
-      final MutableRel left = toMutable(semiJoin.getLeft());
-      final MutableRel right = toMutable(semiJoin.getRight());
-      return MutableSemiJoin.of(semiJoin.getRowType(), left, right,
-          semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys());
-    }
     if (rel instanceof Join) {
       final Join join = (Join) rel;
       final MutableRel left = toMutable(join.getLeft());
diff --git a/core/src/main/java/org/apache/calcite/rel/mutable/MutableSemiJoin.java b/core/src/main/java/org/apache/calcite/rel/mutable/MutableSemiJoin.java
deleted file mode 100644
index 5806696..0000000
--- a/core/src/main/java/org/apache/calcite/rel/mutable/MutableSemiJoin.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.rel.mutable;
-
-import org.apache.calcite.rel.type.RelDataType;
-import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.util.ImmutableIntList;
-
-import java.util.Objects;
-
-/** Mutable equivalent of {@link org.apache.calcite.rel.core.SemiJoin}. */
-public class MutableSemiJoin extends MutableBiRel {
-  public final RexNode condition;
-  public final ImmutableIntList leftKeys;
-  public final ImmutableIntList rightKeys;
-
-  private MutableSemiJoin(
-      RelDataType rowType,
-      MutableRel left,
-      MutableRel right,
-      RexNode condition,
-      ImmutableIntList leftKeys,
-      ImmutableIntList rightKeys) {
-    super(MutableRelType.SEMIJOIN, left.cluster, rowType, left, right);
-    this.condition = condition;
-    this.leftKeys = leftKeys;
-    this.rightKeys = rightKeys;
-  }
-
-  /**
-   * Creates a MutableSemiJoin.
-   *
-   * @param rowType   Row type
-   * @param left      Left input relational expression
-   * @param right     Right input relational expression
-   * @param condition Join condition
-   * @param leftKeys  Left join keys
-   * @param rightKeys Right join keys
-   */
-  public static MutableSemiJoin of(RelDataType rowType, MutableRel left,
-      MutableRel right, RexNode condition, ImmutableIntList leftKeys,
-      ImmutableIntList rightKeys) {
-    return new MutableSemiJoin(rowType, left, right, condition, leftKeys,
-        rightKeys);
-  }
-
-  @Override public boolean equals(Object obj) {
-    return obj == this
-        || obj instanceof MutableSemiJoin
-        && condition.equals(((MutableSemiJoin) obj).condition)
-        && leftKeys.equals(((MutableSemiJoin) obj).leftKeys)
-        && rightKeys.equals(((MutableSemiJoin) obj).rightKeys)
-        && left.equals(((MutableSemiJoin) obj).left)
-        && right.equals(((MutableSemiJoin) obj).right);
-  }
-
-  @Override public int hashCode() {
-    return Objects.hash(left, right, condition, leftKeys, rightKeys);
-  }
-
-  @Override public StringBuilder digest(StringBuilder buf) {
-    return buf.append("SemiJoin(condition: ").append(condition)
-        .append(", leftKeys: ").append(leftKeys)
-        .append(", rightKeys: ").append(rightKeys)
-        .append(")");
-  }
-
-  @Override public MutableRel clone() {
-    return MutableSemiJoin.of(rowType, left.clone(),
-        right.clone(), condition, leftKeys, rightKeys);
-  }
-}
-
-// End MutableSemiJoin.java
diff --git a/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java b/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
index dcc7e45..c6a707d 100644
--- a/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
+++ b/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
@@ -81,7 +81,6 @@ import com.google.common.collect.Ordering;
 
 import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Deque;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -460,7 +459,7 @@ public class RelToSqlConverter extends SqlImplementor
     // Use condition 1=0 since "where false" does not seem to be supported
     // on some DB vendors.
     return SqlStdOperatorTable.EQUALS.createCall(POS,
-            Arrays.asList(SqlLiteral.createExactNumeric("1", POS),
+            ImmutableList.of(SqlLiteral.createExactNumeric("1", POS),
                     SqlLiteral.createExactNumeric("0", POS)));
   }
 
@@ -535,10 +534,10 @@ public class RelToSqlConverter extends SqlImplementor
     return !dialect.supportsAggregateFunction(SqlKind.ROLLUP)
         && dialect.supportsGroupByWithRollup()
         && (aggregate.getGroupType() == Aggregate.Group.ROLLUP
-        || aggregate.getGroupType() == Aggregate.Group.CUBE
-        && aggregate.getGroupSet().cardinality() == 1)
+            || aggregate.getGroupType() == Aggregate.Group.CUBE
+                && aggregate.getGroupSet().cardinality() == 1)
         && e.collation.getFieldCollations().stream().allMatch(fc ->
-        fc.getFieldIndex() < aggregate.getGroupSet().cardinality());
+            fc.getFieldIndex() < aggregate.getGroupSet().cardinality());
   }
 
   /** @see #dispatch */
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/JoinToCorrelateRule.java b/core/src/main/java/org/apache/calcite/rel/rules/JoinToCorrelateRule.java
index 8f5de4b..66c7984 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/JoinToCorrelateRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/JoinToCorrelateRule.java
@@ -72,18 +72,6 @@ public class JoinToCorrelateRule extends RelOptRule {
    * {@code JOIN} is not deprecated, but {@code INSTANCE} is preferred. */
   public static final JoinToCorrelateRule JOIN = INSTANCE;
 
-  /**
-   * Rule that converts a {@link org.apache.calcite.rel.core.SemiJoin}
-   * into a {@link org.apache.calcite.rel.logical.LogicalCorrelate}
-   *
-   * @deprecated Will be unnecessary when {@code SemiJoin} is removed before
-   * 1.21, and will be removed at that time.
-   */
-  @Deprecated // to be removed before 1.21
-  public static final JoinToCorrelateRule SEMI =
-      new JoinToCorrelateRule(org.apache.calcite.rel.core.SemiJoin.class,
-          RelFactories.LOGICAL_BUILDER, "SemiJoinToCorrelateRule");
-
   //~ Constructors -----------------------------------------------------------
 
   /**
diff --git a/core/src/main/java/org/apache/calcite/sql/SemiJoinType.java b/core/src/main/java/org/apache/calcite/sql/SemiJoinType.java
index e9c724f..2e2d16c 100644
--- a/core/src/main/java/org/apache/calcite/sql/SemiJoinType.java
+++ b/core/src/main/java/org/apache/calcite/sql/SemiJoinType.java
@@ -16,7 +16,7 @@
  */
 package org.apache.calcite.sql;
 
-import org.apache.calcite.linq4j.CorrelateJoinType;
+import org.apache.calcite.linq4j.JoinType;
 import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.sql.parser.SqlParserPos;
 
@@ -102,16 +102,16 @@ public enum SemiJoinType {
         "Unable to convert " + this + " to JoinRelType");
   }
 
-  public CorrelateJoinType toLinq4j() {
+  public JoinType toLinq4j() {
     switch (this) {
     case INNER:
-      return CorrelateJoinType.INNER;
+      return JoinType.INNER;
     case LEFT:
-      return CorrelateJoinType.LEFT;
+      return JoinType.LEFT;
     case SEMI:
-      return CorrelateJoinType.SEMI;
+      return JoinType.SEMI;
     case ANTI:
-      return CorrelateJoinType.ANTI;
+      return JoinType.ANTI;
     }
     throw new IllegalStateException(
         "Unable to convert " + this + " to JoinRelType");
diff --git a/core/src/main/java/org/apache/calcite/tools/Programs.java b/core/src/main/java/org/apache/calcite/tools/Programs.java
index fb1abfa..819aee4 100644
--- a/core/src/main/java/org/apache/calcite/tools/Programs.java
+++ b/core/src/main/java/org/apache/calcite/tools/Programs.java
@@ -82,14 +82,10 @@ public class Programs {
   public static final Program SUB_QUERY_PROGRAM =
       subQuery(DefaultRelMetadataProvider.INSTANCE);
 
-  @SuppressWarnings("deprecation") // directive to be removed before 1.21
   public static final ImmutableSet<RelOptRule> RULE_SET =
       ImmutableSet.of(
           EnumerableRules.ENUMERABLE_JOIN_RULE,
           EnumerableRules.ENUMERABLE_MERGE_JOIN_RULE,
-          // The following line is to be removed before 1.21;
-          // when it is removed, also remove SuppressWarnings directive, above
-          EnumerableRules.ENUMERABLE_SEMI_JOIN_RULE,
           EnumerableRules.ENUMERABLE_CORRELATE_RULE,
           EnumerableRules.ENUMERABLE_PROJECT_RULE,
           EnumerableRules.ENUMERABLE_FILTER_RULE,