diff --git a/core/src/main/java/org/apache/calcite/plan/Convention.java b/core/src/main/java/org/apache/calcite/plan/Convention.java index 059726b4ed77..47bfe99e39b6 100644 --- a/core/src/main/java/org/apache/calcite/plan/Convention.java +++ b/core/src/main/java/org/apache/calcite/plan/Convention.java @@ -84,7 +84,7 @@ default boolean useAbstractConvertersForConversion(RelTraitSet fromTraits, return false; } - /** Return RelFactories struct for this convention. It can can be used to + /** Return RelFactories struct for this convention. It can be used to * build RelNode. */ default RelFactories.Struct getRelFactories() { return RelFactories.DEFAULT_STRUCT; diff --git a/core/src/main/java/org/apache/calcite/rel/rules/AggregateStarTableRule.java b/core/src/main/java/org/apache/calcite/rel/rules/AggregateStarTableRule.java index 7b2e9a16961b..95a604c7d6d3 100644 --- a/core/src/main/java/org/apache/calcite/rel/rules/AggregateStarTableRule.java +++ b/core/src/main/java/org/apache/calcite/rel/rules/AggregateStarTableRule.java @@ -98,7 +98,7 @@ protected void apply(RelOptRuleCall call, @Nullable Project postProject, final Optional config = planner.getContext().maybeUnwrap(CalciteConnectionConfig.class); if (!(config.isPresent() && config.get().createMaterializations())) { - // Disable this rule if we if materializations are disabled - in + // Disable this rule if materializations are disabled - in // particular, if we are in a recursive statement that is being used to // populate a materialization return; diff --git a/core/src/main/java/org/apache/calcite/rel/rules/CoreRules.java b/core/src/main/java/org/apache/calcite/rel/rules/CoreRules.java index 24a104f1518e..aca746905d47 100644 --- a/core/src/main/java/org/apache/calcite/rel/rules/CoreRules.java +++ b/core/src/main/java/org/apache/calcite/rel/rules/CoreRules.java @@ -272,7 +272,7 @@ private CoreRules() {} * {@link org.apache.calcite.rel.rules.FilterProjectTransposeRule}. * *

It does not allow a Filter to be pushed past the Project if - * {@link RexUtil#containsCorrelation there is a correlation condition}) + * {@link RexUtil#containsCorrelation there is a correlation condition} * anywhere in the Filter, since in some cases it can prevent a * {@link Correlate} from being de-correlated. */ diff --git a/core/src/main/java/org/apache/calcite/rel/rules/FilterToCalcRule.java b/core/src/main/java/org/apache/calcite/rel/rules/FilterToCalcRule.java index 5b0a4d4f605a..cdeffc0fa6d2 100644 --- a/core/src/main/java/org/apache/calcite/rel/rules/FilterToCalcRule.java +++ b/core/src/main/java/org/apache/calcite/rel/rules/FilterToCalcRule.java @@ -36,7 +36,7 @@ * *

The rule does NOT fire if the child is a * {@link org.apache.calcite.rel.logical.LogicalFilter} or a - * {@link org.apache.calcite.rel.logical.LogicalProject} (we assume they they + * {@link org.apache.calcite.rel.logical.LogicalProject} (we assume that they * will be converted using {@link FilterToCalcRule} or * {@link ProjectToCalcRule}) or a * {@link org.apache.calcite.rel.logical.LogicalCalc}. This diff --git a/core/src/main/java/org/apache/calcite/rex/RexProgramBuilder.java b/core/src/main/java/org/apache/calcite/rex/RexProgramBuilder.java index 2064c4fb85a9..40d2c9a7595b 100644 --- a/core/src/main/java/org/apache/calcite/rex/RexProgramBuilder.java +++ b/core/src/main/java/org/apache/calcite/rex/RexProgramBuilder.java @@ -80,7 +80,7 @@ private RexProgramBuilder(RelDataType inputRowType, RexBuilder rexBuilder, if (inputRowType.isStruct()) { final List fields = inputRowType.getFieldList(); for (int i = 0; i < fields.size(); i++) { - registerInternal(RexInputRef.of(i, fields), false); + registerInternal(RexInputRef.of(i, fields)); } } } @@ -322,14 +322,9 @@ public RexLocalRef registerOutput(RexNode expr) { * Registers an expression in the list of common sub-expressions, and * returns a reference to that expression. * - *

If an equivalent sub-expression already exists, creates another - * expression only if force is true. - * - * @param expr Expression to register - * @param force Whether to create a new sub-expression if an equivalent - * sub-expression exists. + * @param expr Expression to register */ - private RexLocalRef registerInternal(RexNode expr, boolean force) { + private RexLocalRef registerInternal(RexNode expr) { final RexSimplify simplify = new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, RexUtil.EXECUTOR); expr = simplify.simplifyPreservingType(expr); @@ -353,11 +348,6 @@ private RexLocalRef registerInternal(RexNode expr, boolean force) { // Add expression to list, and return a new reference to it. ref = addExpr(expr); exprMap.put(requireNonNull(key, "key"), ref); - } else { - if (force) { - // Add expression to list, but return the previous ref. - addExpr(expr); - } } for (;;) { @@ -895,37 +885,37 @@ public List getProjectList() { private abstract class RegisterShuttle extends RexShuttle { @Override public RexNode visitCall(RexCall call) { final RexNode expr = super.visitCall(call); - return registerInternal(expr, false); + return registerInternal(expr); } @Override public RexNode visitOver(RexOver over) { final RexNode expr = super.visitOver(over); - return registerInternal(expr, false); + return registerInternal(expr); } @Override public RexNode visitLiteral(RexLiteral literal) { final RexNode expr = super.visitLiteral(literal); - return registerInternal(expr, false); + return registerInternal(expr); } @Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode expr = super.visitFieldAccess(fieldAccess); - return registerInternal(expr, false); + return registerInternal(expr); } @Override public RexNode visitDynamicParam(RexDynamicParam dynamicParam) { final RexNode expr = super.visitDynamicParam(dynamicParam); - return registerInternal(expr, false); + return registerInternal(expr); } @Override public RexNode visitCorrelVariable(RexCorrelVariable variable) { final RexNode expr = super.visitCorrelVariable(variable); - return registerInternal(expr, false); + return registerInternal(expr); } @Override public RexNode visitLambda(RexLambda lambda) { super.visitLambda(lambda); - return registerInternal(lambda, false); + return registerInternal(lambda); } } @@ -996,7 +986,7 @@ protected RegisterInputShuttle(boolean valid) { // Add expression to the list, just so that subsequent // expressions don't get screwed up. This expression is // unused, so will be eliminated soon. - return registerInternal(local, false); + return registerInternal(local); } } } diff --git a/core/src/main/java/org/apache/calcite/util/mapping/Mappings.java b/core/src/main/java/org/apache/calcite/util/mapping/Mappings.java index c476a96edbce..8b000032ac92 100644 --- a/core/src/main/java/org/apache/calcite/util/mapping/Mappings.java +++ b/core/src/main/java/org/apache/calcite/util/mapping/Mappings.java @@ -528,8 +528,8 @@ public static TargetMapping createShiftMapping( final TargetMapping mapping = create( MappingType.INVERSE_SURJECTION, - sourceCount, // aCount + bCount + cCount, - targetCount); // cCount + bCount + sourceCount, + targetCount); for (int i = 0; i < ints.length; i += 3) { final int target = ints[i];