You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2018/07/09 07:49:35 UTC
[13/30] calcite git commit: [CALCITE-2259] Allow Java 8 syntax
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql2rel/ReflectiveConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/ReflectiveConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/ReflectiveConvertletTable.java
index 4d87df1..314970a 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/ReflectiveConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/ReflectiveConvertletTable.java
@@ -78,19 +78,14 @@ public class ReflectiveConvertletTable implements SqlRexConvertletTable {
if (!SqlNode.class.isAssignableFrom(parameterType)) {
return;
}
- map.put(parameterType,
- new SqlRexConvertlet() {
- public RexNode convertCall(
- SqlRexContext cx,
- SqlCall call) {
- try {
- return (RexNode) method.invoke(ReflectiveConvertletTable.this,
- cx, call);
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new RuntimeException("while converting " + call, e);
- }
- }
- });
+ map.put(parameterType, (SqlRexConvertlet) (cx, call) -> {
+ try {
+ return (RexNode) method.invoke(ReflectiveConvertletTable.this,
+ cx, call);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException("while converting " + call, e);
+ }
+ });
}
/**
@@ -124,17 +119,14 @@ public class ReflectiveConvertletTable implements SqlRexConvertletTable {
if (!SqlCall.class.isAssignableFrom(parameterType)) {
return;
}
- map.put(opClass,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- try {
- return (RexNode) method.invoke(ReflectiveConvertletTable.this,
- cx, call.getOperator(), call);
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new RuntimeException("while converting " + call, e);
- }
- }
- });
+ map.put(opClass, (SqlRexConvertlet) (cx, call) -> {
+ try {
+ return (RexNode) method.invoke(ReflectiveConvertletTable.this,
+ cx, call.getOperator(), call);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException("while converting " + call, e);
+ }
+ });
}
public SqlRexConvertlet get(SqlCall call) {
@@ -191,17 +183,12 @@ public class ReflectiveConvertletTable implements SqlRexConvertletTable {
*/
protected void addAlias(final SqlOperator alias, final SqlOperator target) {
map.put(
- alias,
- new SqlRexConvertlet() {
- public RexNode convertCall(
- SqlRexContext cx,
- SqlCall call) {
- Preconditions.checkArgument(call.getOperator() == alias,
- "call to wrong operator");
- final SqlCall newCall =
- target.createCall(SqlParserPos.ZERO, call.getOperandList());
- return cx.convertExpression(newCall);
- }
+ alias, (SqlRexConvertlet) (cx, call) -> {
+ Preconditions.checkArgument(call.getOperator() == alias,
+ "call to wrong operator");
+ final SqlCall newCall =
+ target.createCall(SqlParserPos.ZERO, call.getOperandList());
+ return cx.convertExpression(newCall);
});
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index 7d9bf1e..9deb7e0 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -87,18 +87,14 @@ import org.apache.calcite.util.Util;
import org.apache.calcite.util.mapping.Mappings;
import org.apache.calcite.util.trace.CalciteTrace;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
+import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets;
import com.google.common.collect.SortedSetMultimap;
@@ -119,7 +115,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.TreeSet;
import javax.annotation.Nonnull;
/**
@@ -165,7 +160,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
* positions. This is from the view point of the parent rel of a new rel. */
private final Map<RelNode, Frame> map = new HashMap<>();
- private final HashSet<LogicalCorrelate> generatedCorRels = Sets.newHashSet();
+ private final HashSet<LogicalCorrelate> generatedCorRels = new HashSet<>();
//~ Constructors -----------------------------------------------------------
@@ -282,26 +277,24 @@ public class RelDecorrelator implements ReflectiveVisitor {
}
private Function2<RelNode, RelNode, Void> createCopyHook() {
- return new Function2<RelNode, RelNode, Void>() {
- public Void apply(RelNode oldNode, RelNode newNode) {
- if (cm.mapRefRelToCorRef.containsKey(oldNode)) {
- cm.mapRefRelToCorRef.putAll(newNode,
- cm.mapRefRelToCorRef.get(oldNode));
+ return (oldNode, newNode) -> {
+ if (cm.mapRefRelToCorRef.containsKey(oldNode)) {
+ cm.mapRefRelToCorRef.putAll(newNode,
+ cm.mapRefRelToCorRef.get(oldNode));
+ }
+ if (oldNode instanceof LogicalCorrelate
+ && newNode instanceof LogicalCorrelate) {
+ LogicalCorrelate oldCor = (LogicalCorrelate) oldNode;
+ CorrelationId c = oldCor.getCorrelationId();
+ if (cm.mapCorToCorRel.get(c) == oldNode) {
+ cm.mapCorToCorRel.put(c, newNode);
}
- if (oldNode instanceof LogicalCorrelate
- && newNode instanceof LogicalCorrelate) {
- LogicalCorrelate oldCor = (LogicalCorrelate) oldNode;
- CorrelationId c = oldCor.getCorrelationId();
- if (cm.mapCorToCorRel.get(c) == oldNode) {
- cm.mapCorToCorRel.put(c, newNode);
- }
- if (generatedCorRels.contains(oldNode)) {
- generatedCorRels.add((LogicalCorrelate) newNode);
- }
+ if (generatedCorRels.contains(oldNode)) {
+ generatedCorRels.add((LogicalCorrelate) newNode);
}
- return null;
}
+ return null;
};
}
@@ -342,7 +335,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
boolean projectPulledAboveLeftCorrelator) {
RemoveCorrelationRexShuttle shuttle =
new RemoveCorrelationRexShuttle(relBuilder.getRexBuilder(),
- projectPulledAboveLeftCorrelator, null, ImmutableSet.<Integer>of());
+ projectPulledAboveLeftCorrelator, null, ImmutableSet.of());
return exp.accept(shuttle);
}
@@ -353,7 +346,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
RemoveCorrelationRexShuttle shuttle =
new RemoveCorrelationRexShuttle(relBuilder.getRexBuilder(),
projectPulledAboveLeftCorrelator, nullIndicator,
- ImmutableSet.<Integer>of());
+ ImmutableSet.of());
return exp.accept(shuttle);
}
@@ -373,7 +366,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
if (rel.getInputs().size() > 0) {
List<RelNode> oldInputs = rel.getInputs();
- List<RelNode> newInputs = Lists.newArrayList();
+ List<RelNode> newInputs = new ArrayList<>();
for (int i = 0; i < oldInputs.size(); ++i) {
final Frame frame = getInvoke(oldInputs.get(i), rel);
if (frame == null || !frame.corDefOutputs.isEmpty()) {
@@ -393,7 +386,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// the output position should not change since there are no corVars
// coming from below.
return register(rel, newRel, identityMap(rel.getRowType().getFieldCount()),
- ImmutableSortedMap.<CorDef, Integer>of());
+ ImmutableSortedMap.of());
}
/**
@@ -485,7 +478,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// Project projects the original expressions,
// plus any correlated variables the input wants to pass along.
- final List<Pair<RexNode, String>> projects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> projects = new ArrayList<>();
List<RelDataTypeField> newInputOutput =
newInput.getRowType().getFieldList();
@@ -554,7 +547,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// oldInput ----> newProject
// |
// newInput
- Map<Integer, Integer> combinedMap = Maps.newHashMap();
+ Map<Integer, Integer> combinedMap = new HashMap<>();
for (Integer oldInputPos : frame.oldToNewOutputs.keySet()) {
combinedMap.put(oldInputPos,
@@ -566,7 +559,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// now it's time to rewrite the Aggregate
final ImmutableBitSet newGroupSet = ImmutableBitSet.range(newGroupKeyCount);
- List<AggregateCall> newAggCalls = Lists.newArrayList();
+ List<AggregateCall> newAggCalls = new ArrayList<>();
List<AggregateCall> oldAggCalls = rel.getAggCallList();
int oldInputOutputFieldCount = rel.getGroupSet().cardinality();
@@ -577,7 +570,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
++i;
List<Integer> oldAggArgs = oldAggCall.getArgList();
- List<Integer> aggArgs = Lists.newArrayList();
+ List<Integer> aggArgs = new ArrayList<>();
// Adjust the Aggregate argument positions.
// Note Aggregate does not change input ordering, so the input
@@ -662,7 +655,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// Project projects the original expressions,
// plus any correlated variables the input wants to pass along.
- final List<Pair<RexNode, String>> projects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> projects = new ArrayList<>();
// If this Project has correlated reference, create value generator
// and produce the correlated variables in the new output.
@@ -779,7 +772,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
r =
LogicalJoin.create(r, distinct,
cluster.getRexBuilder().makeLiteral(true),
- ImmutableSet.<CorrelationId>of(), JoinRelType.INNER);
+ ImmutableSet.of(), JoinRelType.INNER);
}
}
}
@@ -818,7 +811,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
private Frame getFrame(RelNode r, boolean safe) {
final Frame frame = map.get(r);
if (frame == null && safe) {
- return new Frame(r, r, ImmutableSortedMap.<CorDef, Integer>of(),
+ return new Frame(r, r, ImmutableSortedMap.of(),
identityMap(r.getRowType().getFieldCount()));
}
return frame;
@@ -926,7 +919,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
RelNode join =
LogicalJoin.create(frame.r, valueGen, relBuilder.literal(true),
- ImmutableSet.<CorrelationId>of(), JoinRelType.INNER);
+ ImmutableSet.of(), JoinRelType.INNER);
// Join or Filter does not change the old input ordering. All
// input fields from newLeftInput (i.e. the original input to the old
@@ -1145,7 +1138,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
false);
RelNode newJoin =
LogicalJoin.create(leftFrame.r, rightFrame.r, condition,
- ImmutableSet.<CorrelationId>of(), rel.getJoinType().toJoinType());
+ ImmutableSet.of(), rel.getJoinType().toJoinType());
return register(rel, newJoin, mapOldToNewOutputs, corDefOutputs);
}
@@ -1177,11 +1170,11 @@ public class RelDecorrelator implements ReflectiveVisitor {
final RelNode newJoin =
LogicalJoin.create(leftFrame.r, rightFrame.r,
decorrelateExpr(currentRel, map, cm, rel.getCondition()),
- ImmutableSet.<CorrelationId>of(), rel.getJoinType());
+ ImmutableSet.of(), rel.getJoinType());
// Create the mapping between the output of the old correlation rel
// and the new join rel
- Map<Integer, Integer> mapOldToNewOutputs = Maps.newHashMap();
+ Map<Integer, Integer> mapOldToNewOutputs = new HashMap<>();
int oldLeftFieldCount = oldLeft.getRowType().getFieldCount();
int newLeftFieldCount = leftFrame.r.getRowType().getFieldCount();
@@ -1281,7 +1274,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
true));
// now create the new project
- List<Pair<RexNode, String>> newProjExprs = Lists.newArrayList();
+ List<Pair<RexNode, String>> newProjExprs = new ArrayList<>();
// project everything from the LHS and then those from the original
// projRel
@@ -1331,7 +1324,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
final JoinRelType joinType = correlate.getJoinType().toJoinType();
// now create the new project
- final List<Pair<RexNode, String>> newProjects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> newProjects = new ArrayList<>();
// Project everything from the LHS and then those from the original
// project
@@ -1441,7 +1434,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
List<Pair<RexNode, String>> additionalExprs) {
final List<RelDataTypeField> fieldList =
input.getRowType().getFieldList();
- List<Pair<RexNode, String>> projects = Lists.newArrayList();
+ List<Pair<RexNode, String>> projects = new ArrayList<>();
for (Ord<RelDataTypeField> field : Ord.zip(fieldList)) {
projects.add(
Pair.of(
@@ -1502,9 +1495,9 @@ public class RelDecorrelator implements ReflectiveVisitor {
private DecorrelateRexShuttle(RelNode currentRel,
Map<RelNode, Frame> map, CorelMap cm) {
- this.currentRel = Preconditions.checkNotNull(currentRel);
- this.map = Preconditions.checkNotNull(map);
- this.cm = Preconditions.checkNotNull(cm);
+ this.currentRel = Objects.requireNonNull(currentRel);
+ this.map = Objects.requireNonNull(map);
+ this.cm = Objects.requireNonNull(cm);
}
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) {
@@ -1886,8 +1879,8 @@ public class RelDecorrelator implements ReflectiveVisitor {
// filterInput) and correlatedJoinKeys. correlatedJoinKeys
// can be expressions, while rightJoinKeys need to be input
// refs. These comparisons are AND'ed together.
- List<RexNode> tmpRightJoinKeys = Lists.newArrayList();
- List<RexNode> correlatedJoinKeys = Lists.newArrayList();
+ List<RexNode> tmpRightJoinKeys = new ArrayList<>();
+ List<RexNode> correlatedJoinKeys = new ArrayList<>();
RelOptUtil.splitCorrelatedFilterCondition(
filter,
tmpRightJoinKeys,
@@ -1985,7 +1978,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// make the new join rel
LogicalJoin join =
LogicalJoin.create(left, right, joinCond,
- ImmutableSet.<CorrelationId>of(), joinType);
+ ImmutableSet.of(), joinType);
RelNode newProject =
projectJoinOutputWithNullability(join, project, nullIndicatorPos);
@@ -2004,7 +1997,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
operand(LogicalCorrelate.class,
operand(RelNode.class, any()),
operand(LogicalProject.class,
- operand(LogicalAggregate.class, null, Aggregate.IS_SIMPLE,
+ operandJ(LogicalAggregate.class, null, Aggregate::isSimple,
operand(LogicalProject.class,
operand(RelNode.class, any()))))),
relBuilderFactory, null);
@@ -2057,7 +2050,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
final List<RexNode> aggInputProjects = aggInputProject.getProjects();
final List<AggregateCall> aggCalls = aggregate.getAggCallList();
- final Set<Integer> isCountStar = Sets.newHashSet();
+ final Set<Integer> isCountStar = new HashSet<>();
// mark if agg produces count(*) which needs to reference the
// nullIndicator after the transformation.
@@ -2095,8 +2088,8 @@ public class RelDecorrelator implements ReflectiveVisitor {
// filterInput) and correlatedJoinKeys. correlatedJoinKeys
// can only be RexFieldAccess, while rightJoinKeys can be
// expressions. These comparisons are AND'ed together.
- List<RexNode> rightJoinKeys = Lists.newArrayList();
- List<RexNode> tmpCorrelatedJoinKeys = Lists.newArrayList();
+ List<RexNode> rightJoinKeys = new ArrayList<>();
+ List<RexNode> tmpCorrelatedJoinKeys = new ArrayList<>();
RelOptUtil.splitCorrelatedFilterCondition(
filter,
rightJoinKeys,
@@ -2106,8 +2099,8 @@ public class RelDecorrelator implements ReflectiveVisitor {
// make sure the correlated reference forms a unique key check
// that the columns referenced in these comparisons form an
// unique key of the leftInput
- List<RexFieldAccess> correlatedJoinKeys = Lists.newArrayList();
- List<RexInputRef> correlatedInputRefJoinKeys = Lists.newArrayList();
+ List<RexFieldAccess> correlatedJoinKeys = new ArrayList<>();
+ List<RexInputRef> correlatedInputRefJoinKeys = new ArrayList<>();
for (RexNode joinKey : tmpCorrelatedJoinKeys) {
assert joinKey instanceof RexFieldAccess;
correlatedJoinKeys.add((RexFieldAccess) joinKey);
@@ -2261,12 +2254,12 @@ public class RelDecorrelator implements ReflectiveVisitor {
right =
createProjectWithAdditionalExprs(right,
ImmutableList.of(
- Pair.<RexNode, String>of(rexBuilder.makeLiteral(true),
+ Pair.of(rexBuilder.makeLiteral(true),
"nullIndicator")));
LogicalJoin join =
LogicalJoin.create(left, right, joinCond,
- ImmutableSet.<CorrelationId>of(), joinType);
+ ImmutableSet.of(), joinType);
// To the consumer of joinOutputProjRel, nullIndicator is located
// at the end
@@ -2281,7 +2274,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
true));
// first project all group-by keys plus the transformed agg input
- List<RexNode> joinOutputProjects = Lists.newArrayList();
+ List<RexNode> joinOutputProjects = new ArrayList<>();
// LOJ Join preserves LHS types
for (int i = 0; i < leftInputFieldCount; i++) {
@@ -2310,7 +2303,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
final int groupCount = leftInputFieldCount;
- List<AggregateCall> newAggCalls = Lists.newArrayList();
+ List<AggregateCall> newAggCalls = new ArrayList<>();
k = -1;
for (AggregateCall aggCall : aggCalls) {
++k;
@@ -2321,7 +2314,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
// the null indicator is located at the end
argList = Collections.singletonList(nullIndicatorPos);
} else {
- argList = Lists.newArrayList();
+ argList = new ArrayList<>();
for (int aggArg : aggCall.getArgList()) {
argList.add(aggArg + groupCount);
@@ -2340,7 +2333,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
LogicalAggregate newAggregate =
LogicalAggregate.create(joinOutputProject, groupSet, null,
newAggCalls);
- List<RexNode> newAggOutputProjectList = Lists.newArrayList();
+ List<RexNode> newAggOutputProjectList = new ArrayList<>();
for (int i : groupSet) {
newAggOutputProjectList.add(
rexBuilder.makeInputRef(newAggregate, i));
@@ -2402,7 +2395,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
aggregate = call.rel(2);
// Create identity projection
- final List<Pair<RexNode, String>> projects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> projects = new ArrayList<>();
final List<RelDataTypeField> fields =
aggregate.getRowType().getFieldList();
for (int i = 0; i < fields.size(); i++) {
@@ -2460,7 +2453,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
}
List<AggregateCall> aggCalls = aggregate.getAggCallList();
- Set<Integer> isCount = Sets.newHashSet();
+ Set<Integer> isCount = new HashSet<>();
// remember the count() positions
int i = -1;
@@ -2670,14 +2663,9 @@ public class RelDecorrelator implements ReflectiveVisitor {
new TreeMap<>();
final SortedSetMultimap<RelNode, CorRef> mapRefRelToCorRef =
- Multimaps.newSortedSetMultimap(
- new HashMap<RelNode, Collection<CorRef>>(),
- new Supplier<TreeSet<CorRef>>() {
- public TreeSet<CorRef> get() {
- Bug.upgrade("use MultimapBuilder when we're on Guava-16");
- return Sets.newTreeSet();
- }
- });
+ MultimapBuilder.SortedSetMultimapBuilder.hashKeys()
+ .treeSetValues()
+ .build();
final Map<RexFieldAccess, CorRef> mapFieldAccessToCorVar = new HashMap<>();
@@ -2788,7 +2776,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
Frame(RelNode oldRel, RelNode r, SortedMap<CorDef, Integer> corDefOutputs,
Map<Integer, Integer> oldToNewOutputs) {
- this.r = Preconditions.checkNotNull(r);
+ this.r = Objects.requireNonNull(r);
this.corDefOutputs = ImmutableSortedMap.copyOf(corDefOutputs);
this.oldToNewOutputs = ImmutableSortedMap.copyOf(oldToNewOutputs);
assert allLessThan(this.corDefOutputs.values(),
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java b/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
index db6588f..733ee02 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
@@ -65,7 +65,6 @@ import org.apache.calcite.util.mapping.Mapping;
import org.apache.calcite.util.mapping.MappingType;
import org.apache.calcite.util.mapping.Mappings;
-import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -613,7 +612,7 @@ public class RelFieldTrimmer implements ReflectiveVisitor {
// on-demand fields.
Set<RelDataTypeField> inputExtraFields =
RelDataTypeImpl.extra(inputRowType) == null
- ? Collections.<RelDataTypeField>emptySet()
+ ? Collections.emptySet()
: combinedInputExtraFields;
inputExtraFieldCounts.add(inputExtraFields.size());
TrimResult trimResult =
@@ -848,11 +847,7 @@ public class RelFieldTrimmer implements ReflectiveVisitor {
final ImmutableList<ImmutableBitSet> newGroupSets =
ImmutableList.copyOf(
Iterables.transform(aggregate.getGroupSets(),
- new Function<ImmutableBitSet, ImmutableBitSet>() {
- public ImmutableBitSet apply(ImmutableBitSet input) {
- return Mappings.apply(inputMapping, input);
- }
- }));
+ input1 -> Mappings.apply(inputMapping, input1)));
// Populate mapping of where to find the fields. System, group key and
// indicator fields first.
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql2rel/RelStructuredTypeFlattener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelStructuredTypeFlattener.java b/core/src/main/java/org/apache/calcite/sql2rel/RelStructuredTypeFlattener.java
index ae830a5..ff41b16 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelStructuredTypeFlattener.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelStructuredTypeFlattener.java
@@ -74,13 +74,13 @@ import org.apache.calcite.util.ReflectiveVisitor;
import org.apache.calcite.util.Util;
import org.apache.calcite.util.mapping.Mappings;
-import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.SortedSetMultimap;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
@@ -131,7 +131,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
private final RexBuilder rexBuilder;
private final boolean restructure;
- private final Map<RelNode, RelNode> oldToNewRelMap = Maps.newHashMap();
+ private final Map<RelNode, RelNode> oldToNewRelMap = new HashMap<>();
private RelNode currentRel;
private int iRestructureInput;
private RelDataType flattenedRootType;
@@ -215,7 +215,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
}
private List<RexNode> restructureFields(RelDataType structuredType) {
- final List<RexNode> structuringExps = Lists.newArrayList();
+ final List<RexNode> structuringExps = new ArrayList<>();
for (RelDataTypeField field : structuredType.getFieldList()) {
// TODO: row
if (field.getType().getSqlTypeName() == SqlTypeName.STRUCTURED) {
@@ -324,11 +324,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
private Mappings.TargetMapping getNewForOldInputMapping(RelNode oldRel) {
final RelNode newRel = getNewForOldRel(oldRel);
return Mappings.target(
- new Function<Integer, Integer>() {
- public Integer apply(Integer oldInput) {
- return getNewForOldInput(oldInput);
- }
- },
+ this::getNewForOldInput,
oldRel.getRowType().getFieldCount(),
newRel.getRowType().getFieldCount());
}
@@ -481,7 +477,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
}
public void rewriteRel(LogicalProject rel) {
- final List<Pair<RexNode, String>> flattenedExpList = Lists.newArrayList();
+ final List<Pair<RexNode, String>> flattenedExpList = new ArrayList<>();
flattenProjections(new RewriteRexShuttle(),
rel.getProjects(),
rel.getRowType().getFieldNames(),
@@ -511,7 +507,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
}
// Convert the projections.
- final List<Pair<RexNode, String>> flattenedExpList = Lists.newArrayList();
+ final List<Pair<RexNode, String>> flattenedExpList = new ArrayList<>();
List<String> fieldNames = rel.getRowType().getFieldNames();
flattenProjections(new RewriteRexShuttle(),
program.getProjectList(),
@@ -593,7 +589,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
for (int j = 0; j < n; ++j) {
RelDataTypeField field = fieldList.get(j);
flattenedExps.add(
- Pair.<RexNode, String>of(
+ Pair.of(
new RexInputRef(newOffset + j, field.getType()),
fieldName));
}
@@ -605,7 +601,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
// For object constructors, prepend a FALSE null
// indicator.
flattenedExps.add(
- Pair.<RexNode, String>of(rexBuilder.makeLiteral(false),
+ Pair.of(rexBuilder.makeLiteral(false),
fieldName));
} else if (exp.isA(SqlKind.CAST)) {
if (RexLiteral.isNullLiteral(
@@ -620,7 +616,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
}
flattenProjections(new RewriteRexShuttle(),
call.getOperands(),
- Collections.<String>nCopies(call.getOperands().size(), null),
+ Collections.nCopies(call.getOperands().size(), null),
fieldName,
flattenedExps);
} else if (exp instanceof RexCall) {
@@ -677,7 +673,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
public void rewriteRel(TableScan rel) {
RelNode newRel = rel.getTable().toRel(toRelContext);
if (!SqlTypeUtil.isFlat(rel.getRowType())) {
- final List<Pair<RexNode, String>> flattenedExpList = Lists.newArrayList();
+ final List<Pair<RexNode, String>> flattenedExpList = new ArrayList<>();
flattenInputs(rel.getRowType().getFieldList(),
rexBuilder.makeRangeReference(newRel),
flattenedExpList);
@@ -861,7 +857,7 @@ public class RelStructuredTypeFlattener implements ReflectiveVisitor {
RexBuilder rexBuilder,
SqlOperator op,
List<RexNode> exprs) {
- final List<Pair<RexNode, String>> flattenedExps = Lists.newArrayList();
+ final List<Pair<RexNode, String>> flattenedExps = new ArrayList<>();
flattenProjections(this, exprs, null, "", flattenedExps);
int n = flattenedExps.size() / 2;
boolean negate = false;
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index 3767e30..0d61247 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -170,16 +170,12 @@ import org.apache.calcite.util.Pair;
import org.apache.calcite.util.Util;
import org.apache.calcite.util.trace.CalciteTrace;
-import com.google.common.base.Function;
import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import org.slf4j.Logger;
@@ -197,8 +193,10 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
+import java.util.function.Supplier;
import static org.apache.calcite.sql.SqlUtil.stripAs;
@@ -317,7 +315,7 @@ public class SqlToRelConverter {
this.subQueryConverter = new NoOpSubQueryConverter();
this.rexBuilder = cluster.getRexBuilder();
this.typeFactory = rexBuilder.getTypeFactory();
- this.cluster = Preconditions.checkNotNull(cluster);
+ this.cluster = Objects.requireNonNull(cluster);
this.exprConverter = new SqlNodeToRexConverterImpl(convertletTable);
this.explainParamCount = 0;
this.config = new ConfigBuilder().withConfig(config).build();
@@ -717,9 +715,9 @@ public class SqlToRelConverter {
return;
}
- final Map<Integer, Integer> squished = Maps.newHashMap();
+ final Map<Integer, Integer> squished = new HashMap<>();
final List<RelDataTypeField> fields = rel.getRowType().getFieldList();
- final List<Pair<RexNode, String>> newProjects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> newProjects = new ArrayList<>();
for (int i = 0; i < fields.size(); i++) {
if (origins.get(i) == i) {
squished.put(i, newProjects.size());
@@ -735,7 +733,7 @@ public class SqlToRelConverter {
// Create the expressions to reverse the mapping.
// Project($0, $1, $0, $2).
- final List<Pair<RexNode, String>> undoProjects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> undoProjects = new ArrayList<>();
for (int i = 0; i < fields.size(); i++) {
final int origin = origins.get(i);
RelDataTypeField field = fields.get(i);
@@ -761,7 +759,7 @@ public class SqlToRelConverter {
final ImmutableBitSet groupSet =
ImmutableBitSet.range(rel.getRowType().getFieldCount());
rel = createAggregate(bb, groupSet, ImmutableList.of(groupSet),
- ImmutableList.<AggregateCall>of());
+ ImmutableList.of());
bb.setRoot(
rel,
@@ -1037,7 +1035,7 @@ public class SqlToRelConverter {
final List<RexNode> leftKeys;
switch (leftKeyNode.getKind()) {
case ROW:
- leftKeys = Lists.newArrayList();
+ leftKeys = new ArrayList<>();
for (SqlNode sqlExpr : ((SqlBasicCall) leftKeyNode).getOperandList()) {
leftKeys.add(bb.convertExpression(sqlExpr));
}
@@ -1107,12 +1105,12 @@ public class SqlToRelConverter {
LogicalAggregate.create(seek, ImmutableBitSet.of(), null,
ImmutableList.of(
AggregateCall.create(SqlStdOperatorTable.COUNT, false,
- false, ImmutableList.<Integer>of(), -1, longType, null),
+ false, ImmutableList.of(), -1, longType, null),
AggregateCall.create(SqlStdOperatorTable.COUNT, false,
false, args, -1, longType, null)));
LogicalJoin join =
LogicalJoin.create(bb.root, aggregate, rexBuilder.makeLiteral(true),
- ImmutableSet.<CorrelationId>of(), JoinRelType.INNER);
+ ImmutableSet.of(), JoinRelType.INNER);
bb.setRoot(join, false);
}
final RexNode rex =
@@ -1426,14 +1424,9 @@ public class SqlToRelConverter {
rexBuilder,
Iterables.transform(
Pair.zip(leftKeys, call.getOperandList()),
- new Function<Pair<RexNode, SqlNode>, RexNode>() {
- public RexNode apply(Pair<RexNode, SqlNode> pair) {
- return rexBuilder.makeCall(comparisonOp,
- pair.left,
- ensureSqlType(pair.left.getType(),
- bb.convertExpression(pair.right)));
- }
- }),
+ pair -> rexBuilder.makeCall(comparisonOp, pair.left,
+ ensureSqlType(pair.left.getType(),
+ bb.convertExpression(pair.right)))),
false);
}
comparisons.add(rexComparison);
@@ -2169,7 +2162,7 @@ public class SqlToRelConverter {
new SqlBasicVisitor<RexNode>() {
@Override public RexNode visit(SqlCall call) {
List<SqlNode> operands = call.getOperandList();
- List<RexNode> newOperands = Lists.newArrayList();
+ List<RexNode> newOperands = new ArrayList<>();
for (SqlNode node : operands) {
newOperands.add(node.accept(this));
}
@@ -2201,7 +2194,7 @@ public class SqlToRelConverter {
// convert subset
final SqlNodeList subsets = matchRecognize.getSubsetList();
- final Map<String, TreeSet<String>> subsetMap = Maps.newHashMap();
+ final Map<String, TreeSet<String>> subsetMap = new HashMap<>();
for (SqlNode node : subsets) {
List<SqlNode> operands = ((SqlCall) node).getOperandList();
SqlIdentifier left = (SqlIdentifier) operands.get(0);
@@ -2411,7 +2404,7 @@ public class SqlToRelConverter {
final Join originalJoin =
(Join) RelFactories.DEFAULT_JOIN_FACTORY.createJoin(leftRel, rightRel,
- joinCond, ImmutableSet.<CorrelationId>of(), joinType, false);
+ joinCond, ImmutableSet.of(), joinType, false);
return RelOptUtil.pushDownJoinConditions(originalJoin, relBuilder);
}
@@ -2423,7 +2416,7 @@ public class SqlToRelConverter {
return null;
}
final ImmutableBitSet.Builder requiredColumns = ImmutableBitSet.builder();
- final List<CorrelationId> correlNames = Lists.newArrayList();
+ final List<CorrelationId> correlNames = new ArrayList<>();
// All correlations must refer the same namespace since correlation
// produces exactly one correlation source.
@@ -2628,7 +2621,7 @@ public class SqlToRelConverter {
SqlValidatorNamespace rightNamespace,
List<String> nameList) {
final SqlNameMatcher nameMatcher = catalogReader.nameMatcher();
- final List<RexNode> list = Lists.newArrayList();
+ final List<RexNode> list = new ArrayList<>();
for (String name : nameList) {
List<RexNode> operands = new ArrayList<>();
int offset = 0;
@@ -2739,7 +2732,7 @@ public class SqlToRelConverter {
}
final RexNode havingExpr;
- final List<Pair<RexNode, String>> projects = Lists.newArrayList();
+ final List<Pair<RexNode, String>> projects = new ArrayList<>();
try {
Preconditions.checkArgument(bb.agg == null, "already in agg mode");
@@ -3222,12 +3215,10 @@ public class SqlToRelConverter {
NullInitializerExpressionFactory.INSTANCE);
// Lazily create a blackboard that contains all non-generated columns.
- final Supplier<Blackboard> bb = new Supplier<Blackboard>() {
- public Blackboard get() {
- RexNode sourceRef = rexBuilder.makeRangeReference(scan);
- return createInsertBlackboard(table, sourceRef,
- table.getRowType().getFieldNames());
- }
+ final Supplier<Blackboard> bb = () -> {
+ RexNode sourceRef = rexBuilder.makeRangeReference(scan);
+ return createInsertBlackboard(table, sourceRef,
+ table.getRowType().getFieldNames());
};
int virtualCount = 0;
@@ -3293,10 +3284,10 @@ public class SqlToRelConverter {
final List<RelDataTypeField> targetFields = targetRowType.getFieldList();
final List<RexNode> sourceExps =
new ArrayList<>(
- Collections.<RexNode>nCopies(targetFields.size(), null));
+ Collections.nCopies(targetFields.size(), null));
final List<String> fieldNames =
new ArrayList<>(
- Collections.<String>nCopies(targetFields.size(), null));
+ Collections.nCopies(targetFields.size(), null));
final InitializerExpressionFactory initializerFactory =
getInitializerFactory(validator.getNamespace(call).getTable());
@@ -3313,12 +3304,8 @@ public class SqlToRelConverter {
}
// Lazily create a blackboard that contains all non-generated columns.
- final Supplier<Blackboard> bb = new Supplier<Blackboard>() {
- public Blackboard get() {
- return createInsertBlackboard(targetTable, sourceRef,
- targetColumnNames);
- }
- };
+ final Supplier<Blackboard> bb = () ->
+ createInsertBlackboard(targetTable, sourceRef, targetColumnNames);
// Walk the expression list and get default values for any columns
// that were not supplied in the statement. Get field names too.
@@ -3795,7 +3782,7 @@ public class SqlToRelConverter {
ret,
relNode,
rexBuilder.makeLiteral(true),
- ImmutableSet.<CorrelationId>of(),
+ ImmutableSet.of(),
JoinRelType.INNER,
false);
}
@@ -4093,12 +4080,12 @@ public class SqlToRelConverter {
final RexNode joinCond;
final int origLeftInputCount = root.getRowType().getFieldCount();
if (leftKeys != null) {
- List<RexNode> newLeftInputExprs = Lists.newArrayList();
+ List<RexNode> newLeftInputExprs = new ArrayList<>();
for (int i = 0; i < origLeftInputCount; i++) {
newLeftInputExprs.add(rexBuilder.makeInputRef(root, i));
}
- final List<Integer> leftJoinKeys = Lists.newArrayList();
+ final List<Integer> leftJoinKeys = new ArrayList<>();
for (RexNode leftKey : leftKeys) {
int index = newLeftInputExprs.indexOf(leftKey);
if (index < 0 || joinType == JoinRelType.LEFT) {
@@ -4307,7 +4294,7 @@ public class SqlToRelConverter {
}
final RexNode c =
rexBuilder.makeCorrel(builder.uniquify().build(), correlId);
- return Pair.<RexNode, Map<String, Integer>>of(c, fields.build());
+ return Pair.of(c, fields.build());
}
}
}
@@ -4504,8 +4491,8 @@ public class SqlToRelConverter {
case CURSOR:
case IN:
case NOT_IN:
- subQuery = Preconditions.checkNotNull(getSubQuery(expr));
- rex = Preconditions.checkNotNull(subQuery.expr);
+ subQuery = Objects.requireNonNull(getSubQuery(expr));
+ rex = Objects.requireNonNull(subQuery.expr);
return StandardConvertletTable.castToValidatedType(expr, rex,
validator, rexBuilder);
@@ -4552,7 +4539,7 @@ public class SqlToRelConverter {
// Apply standard conversions.
rex = expr.accept(this);
- return Preconditions.checkNotNull(rex);
+ return Objects.requireNonNull(rex);
}
/**
@@ -4776,7 +4763,7 @@ public class SqlToRelConverter {
private final Blackboard bb;
public final AggregatingSelectScope aggregatingSelectScope;
- private final Map<String, String> nameMap = Maps.newHashMap();
+ private final Map<String, String> nameMap = new HashMap<>();
/**
* The group-by expressions, in {@link SqlNode} format.
@@ -5246,7 +5233,7 @@ public class SqlToRelConverter {
rexBuilder.getTypeFactory(),
SqlStdOperatorTable.HISTOGRAM_AGG,
exprs,
- ImmutableList.<RelCollation>of());
+ ImmutableList.of());
RexNode over =
rexBuilder.makeOver(
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
index caf5d5d..5714806 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
@@ -19,7 +19,6 @@ package org.apache.calcite.sql2rel;
import org.apache.calcite.avatica.util.DateTimeUtils;
import org.apache.calcite.avatica.util.TimeUnit;
import org.apache.calcite.plan.RelOptUtil;
-import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeFamily;
@@ -96,63 +95,36 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
// Register aliases (operators which have a different name but
// identical behavior to other operators).
- addAlias(
- SqlStdOperatorTable.CHARACTER_LENGTH,
+ addAlias(SqlStdOperatorTable.CHARACTER_LENGTH,
SqlStdOperatorTable.CHAR_LENGTH);
- addAlias(
- SqlStdOperatorTable.IS_UNKNOWN,
+ addAlias(SqlStdOperatorTable.IS_UNKNOWN,
SqlStdOperatorTable.IS_NULL);
- addAlias(
- SqlStdOperatorTable.IS_NOT_UNKNOWN,
+ addAlias(SqlStdOperatorTable.IS_NOT_UNKNOWN,
SqlStdOperatorTable.IS_NOT_NULL);
addAlias(SqlStdOperatorTable.PERCENT_REMAINDER, SqlStdOperatorTable.MOD);
// Register convertlets for specific objects.
- registerOp(
- SqlStdOperatorTable.CAST,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- return convertCast(cx, call);
- }
- });
- registerOp(
- SqlStdOperatorTable.IS_DISTINCT_FROM,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- return convertIsDistinctFrom(cx, call, false);
- }
- });
- registerOp(
- SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- return convertIsDistinctFrom(cx, call, true);
- }
- });
+ registerOp(SqlStdOperatorTable.CAST, this::convertCast);
+ registerOp(SqlStdOperatorTable.IS_DISTINCT_FROM,
+ (cx, call) -> convertIsDistinctFrom(cx, call, false));
+ registerOp(SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
+ (cx, call) -> convertIsDistinctFrom(cx, call, true));
- registerOp(
- SqlStdOperatorTable.PLUS,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- return convertPlus(cx, call);
- }
- });
+ registerOp(SqlStdOperatorTable.PLUS, this::convertPlus);
registerOp(SqlStdOperatorTable.MINUS,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- final RexCall e =
- (RexCall) StandardConvertletTable.this.convertCall(cx, call,
- call.getOperator());
- switch (e.getOperands().get(0).getType().getSqlTypeName()) {
- case DATE:
- case TIME:
- case TIMESTAMP:
- return convertDatetimeMinus(cx, SqlStdOperatorTable.MINUS_DATE,
- call);
- default:
- return e;
- }
+ (cx, call) -> {
+ final RexCall e =
+ (RexCall) StandardConvertletTable.this.convertCall(cx, call,
+ call.getOperator());
+ switch (e.getOperands().get(0).getType().getSqlTypeName()) {
+ case DATE:
+ case TIME:
+ case TIMESTAMP:
+ return convertDatetimeMinus(cx, SqlStdOperatorTable.MINUS_DATE,
+ call);
+ default:
+ return e;
}
});
@@ -165,121 +137,76 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
registerOp(OracleSqlOperatorTable.LEAST, new GreatestConvertlet());
registerOp(OracleSqlOperatorTable.NVL,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- final RexBuilder rexBuilder = cx.getRexBuilder();
- final RexNode operand0 =
- cx.convertExpression(call.getOperandList().get(0));
- final RexNode operand1 =
- cx.convertExpression(call.getOperandList().get(1));
- final RelDataType type =
- cx.getValidator().getValidatedNodeType(call);
- return rexBuilder.makeCall(type, SqlStdOperatorTable.CASE,
- ImmutableList.of(
- rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
- operand0),
- rexBuilder.makeCast(type, operand0),
- rexBuilder.makeCast(type, operand1)));
- }
+ (cx, call) -> {
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ final RexNode operand0 =
+ cx.convertExpression(call.getOperandList().get(0));
+ final RexNode operand1 =
+ cx.convertExpression(call.getOperandList().get(1));
+ final RelDataType type =
+ cx.getValidator().getValidatedNodeType(call);
+ return rexBuilder.makeCall(type, SqlStdOperatorTable.CASE,
+ ImmutableList.of(
+ rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
+ operand0),
+ rexBuilder.makeCast(type, operand0),
+ rexBuilder.makeCast(type, operand1)));
});
registerOp(OracleSqlOperatorTable.DECODE,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- final RexBuilder rexBuilder = cx.getRexBuilder();
- final List<RexNode> operands = convertExpressionList(cx,
- call.getOperandList(), SqlOperandTypeChecker.Consistency.NONE);
- final RelDataType type =
- cx.getValidator().getValidatedNodeType(call);
- final List<RexNode> exprs = new ArrayList<>();
- for (int i = 1; i < operands.size() - 1; i += 2) {
- exprs.add(
- RelOptUtil.isDistinctFrom(rexBuilder, operands.get(0),
- operands.get(i), true));
- exprs.add(operands.get(i + 1));
- }
- if (operands.size() % 2 == 0) {
- exprs.add(Util.last(operands));
- } else {
- exprs.add(rexBuilder.makeNullLiteral(type));
- }
- return rexBuilder.makeCall(type, SqlStdOperatorTable.CASE, exprs);
+ (cx, call) -> {
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ final List<RexNode> operands = convertExpressionList(cx,
+ call.getOperandList(), SqlOperandTypeChecker.Consistency.NONE);
+ final RelDataType type =
+ cx.getValidator().getValidatedNodeType(call);
+ final List<RexNode> exprs = new ArrayList<>();
+ for (int i = 1; i < operands.size() - 1; i += 2) {
+ exprs.add(
+ RelOptUtil.isDistinctFrom(rexBuilder, operands.get(0),
+ operands.get(i), true));
+ exprs.add(operands.get(i + 1));
+ }
+ if (operands.size() % 2 == 0) {
+ exprs.add(Util.last(operands));
+ } else {
+ exprs.add(rexBuilder.makeNullLiteral(type));
}
+ return rexBuilder.makeCall(type, SqlStdOperatorTable.CASE, exprs);
});
// Expand "x NOT LIKE y" into "NOT (x LIKE y)"
- registerOp(
- SqlStdOperatorTable.NOT_LIKE,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- final SqlCall expanded =
- SqlStdOperatorTable.NOT.createCall(
- SqlParserPos.ZERO,
- SqlStdOperatorTable.LIKE.createCall(
- SqlParserPos.ZERO,
- call.getOperandList()));
- return cx.convertExpression(expanded);
- }
- });
+ registerOp(SqlStdOperatorTable.NOT_LIKE,
+ (cx, call) -> cx.convertExpression(
+ SqlStdOperatorTable.NOT.createCall(SqlParserPos.ZERO,
+ SqlStdOperatorTable.LIKE.createCall(SqlParserPos.ZERO,
+ call.getOperandList()))));
// Expand "x NOT SIMILAR y" into "NOT (x SIMILAR y)"
- registerOp(
- SqlStdOperatorTable.NOT_SIMILAR_TO,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- final SqlCall expanded =
- SqlStdOperatorTable.NOT.createCall(
- SqlParserPos.ZERO,
- SqlStdOperatorTable.SIMILAR_TO.createCall(
- SqlParserPos.ZERO,
- call.getOperandList()));
- return cx.convertExpression(expanded);
- }
- });
+ registerOp(SqlStdOperatorTable.NOT_SIMILAR_TO,
+ (cx, call) -> cx.convertExpression(
+ SqlStdOperatorTable.NOT.createCall(SqlParserPos.ZERO,
+ SqlStdOperatorTable.SIMILAR_TO.createCall(SqlParserPos.ZERO,
+ call.getOperandList()))));
// Unary "+" has no effect, so expand "+ x" into "x".
- registerOp(
- SqlStdOperatorTable.UNARY_PLUS,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- SqlNode expanded = call.operand(0);
- return cx.convertExpression(expanded);
- }
- });
+ registerOp(SqlStdOperatorTable.UNARY_PLUS,
+ (cx, call) -> cx.convertExpression(call.operand(0)));
// "DOT"
- registerOp(
- SqlStdOperatorTable.DOT,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- return cx.getRexBuilder().makeCall(SqlStdOperatorTable.DOT,
- cx.convertExpression(call.operand(0)),
- cx.getRexBuilder().makeLiteral(call.operand(1).toString()));
- }
- });
+ registerOp(SqlStdOperatorTable.DOT,
+ (cx, call) -> cx.getRexBuilder().makeCall(SqlStdOperatorTable.DOT,
+ cx.convertExpression(call.operand(0)),
+ cx.getRexBuilder().makeLiteral(call.operand(1).toString())));
// "AS" has no effect, so expand "x AS id" into "x".
- registerOp(
- SqlStdOperatorTable.AS,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- SqlNode expanded = call.operand(0);
- return cx.convertExpression(expanded);
- }
- });
+ registerOp(SqlStdOperatorTable.AS,
+ (cx, call) -> cx.convertExpression(call.operand(0)));
// "SQRT(x)" is equivalent to "POWER(x, .5)"
- registerOp(
- SqlStdOperatorTable.SQRT,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- SqlNode expanded =
- SqlStdOperatorTable.POWER.createCall(
- SqlParserPos.ZERO,
- call.operand(0),
- SqlLiteral.createExactNumeric(
- "0.5", SqlParserPos.ZERO));
- return cx.convertExpression(expanded);
- }
- });
+ registerOp(SqlStdOperatorTable.SQRT,
+ (cx, call) -> cx.convertExpression(
+ SqlStdOperatorTable.POWER.createCall(SqlParserPos.ZERO,
+ call.operand(0),
+ SqlLiteral.createExactNumeric("0.5", SqlParserPos.ZERO))));
// REVIEW jvs 24-Apr-2006: This only seems to be working from within a
// windowed agg. I have added an optimizer rule
@@ -297,26 +224,19 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
// different types, say BIGINT.
//
// Similarly STDDEV_POP and STDDEV_SAMP, VAR_POP and VAR_SAMP.
- registerOp(
- SqlStdOperatorTable.AVG,
+ registerOp(SqlStdOperatorTable.AVG,
new AvgVarianceConvertlet(SqlKind.AVG));
- registerOp(
- SqlStdOperatorTable.STDDEV_POP,
+ registerOp(SqlStdOperatorTable.STDDEV_POP,
new AvgVarianceConvertlet(SqlKind.STDDEV_POP));
- registerOp(
- SqlStdOperatorTable.STDDEV_SAMP,
+ registerOp(SqlStdOperatorTable.STDDEV_SAMP,
new AvgVarianceConvertlet(SqlKind.STDDEV_SAMP));
- registerOp(
- SqlStdOperatorTable.STDDEV,
+ registerOp(SqlStdOperatorTable.STDDEV,
new AvgVarianceConvertlet(SqlKind.STDDEV_SAMP));
- registerOp(
- SqlStdOperatorTable.VAR_POP,
+ registerOp(SqlStdOperatorTable.VAR_POP,
new AvgVarianceConvertlet(SqlKind.VAR_POP));
- registerOp(
- SqlStdOperatorTable.VAR_SAMP,
+ registerOp(SqlStdOperatorTable.VAR_SAMP,
new AvgVarianceConvertlet(SqlKind.VAR_SAMP));
- registerOp(
- SqlStdOperatorTable.VARIANCE,
+ registerOp(SqlStdOperatorTable.VARIANCE,
new AvgVarianceConvertlet(SqlKind.VAR_SAMP));
final SqlRexConvertlet floorCeilConvertlet = new FloorCeilConvertlet();
@@ -330,46 +250,34 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
// Convert "element(<expr>)" to "$element_slice(<expr>)", if the
// expression is a multiset of scalars.
if (false) {
- registerOp(
- SqlStdOperatorTable.ELEMENT,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- assert call.operandCount() == 1;
- final SqlNode operand = call.operand(0);
- final RelDataType type =
- cx.getValidator().getValidatedNodeType(operand);
- if (!type.getComponentType().isStruct()) {
- return cx.convertExpression(
- SqlStdOperatorTable.ELEMENT_SLICE.createCall(
- SqlParserPos.ZERO,
- operand));
- }
-
- // fallback on default behavior
- return StandardConvertletTable.this.convertCall(
- cx,
- call);
+ registerOp(SqlStdOperatorTable.ELEMENT,
+ (cx, call) -> {
+ assert call.operandCount() == 1;
+ final SqlNode operand = call.operand(0);
+ final RelDataType type =
+ cx.getValidator().getValidatedNodeType(operand);
+ if (!type.getComponentType().isStruct()) {
+ return cx.convertExpression(
+ SqlStdOperatorTable.ELEMENT_SLICE.createCall(
+ SqlParserPos.ZERO, operand));
}
+
+ // fallback on default behavior
+ return StandardConvertletTable.this.convertCall(cx, call);
});
}
// Convert "$element_slice(<expr>)" to "element(<expr>).field#0"
if (false) {
- registerOp(
- SqlStdOperatorTable.ELEMENT_SLICE,
- new SqlRexConvertlet() {
- public RexNode convertCall(SqlRexContext cx, SqlCall call) {
- assert call.operandCount() == 1;
- final SqlNode operand = call.operand(0);
- final RexNode expr =
- cx.convertExpression(
- SqlStdOperatorTable.ELEMENT.createCall(
- SqlParserPos.ZERO,
- operand));
- return cx.getRexBuilder().makeFieldAccess(
- expr,
- 0);
- }
+ registerOp(SqlStdOperatorTable.ELEMENT_SLICE,
+ (cx, call) -> {
+ assert call.operandCount() == 1;
+ final SqlNode operand = call.operand(0);
+ final RexNode expr =
+ cx.convertExpression(
+ SqlStdOperatorTable.ELEMENT.createCall(SqlParserPos.ZERO,
+ operand));
+ return cx.getRexBuilder().makeFieldAccess(expr, 0);
});
}
}
@@ -739,7 +647,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
RelDataType returnType =
cx.getValidator().getValidatedNodeType(call);
return cx.getRexBuilder().makeCall(returnType, fun,
- ImmutableList.<RexNode>of(cx.getRexBuilder().makeLiteral(key)));
+ ImmutableList.of(cx.getRexBuilder().makeLiteral(key)));
}
public RexNode convertAggregateFunction(
@@ -759,7 +667,8 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
final int groupCount = cx.getGroupCount();
if (returnType == null) {
RexCallBinding binding =
- new RexCallBinding(cx.getTypeFactory(), fun, exprs, ImmutableList.<RelCollation>of()) {
+ new RexCallBinding(cx.getTypeFactory(), fun, exprs,
+ ImmutableList.of()) {
@Override public int getGroupCount() {
return groupCount;
}
@@ -854,7 +763,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
private static List<RexNode> convertExpressionList(SqlRexContext cx,
List<SqlNode> nodes, SqlOperandTypeChecker.Consistency consistency) {
- final List<RexNode> exprs = Lists.newArrayList();
+ final List<RexNode> exprs = new ArrayList<>();
for (SqlNode node : nodes) {
exprs.add(cx.convertExpression(node));
}
@@ -880,7 +789,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
// All arguments are of same family. No need for explicit casts.
return null;
}
- final List<RelDataType> nonCharacterTypes = Lists.newArrayList();
+ final List<RelDataType> nonCharacterTypes = new ArrayList<>();
for (RelDataType type : types) {
if (type.getFamily() != SqlTypeFamily.CHARACTER) {
nonCharacterTypes.add(type);
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/tools/Frameworks.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/Frameworks.java b/core/src/main/java/org/apache/calcite/tools/Frameworks.java
index 364e592..ee0549b 100644
--- a/core/src/main/java/org/apache/calcite/tools/Frameworks.java
+++ b/core/src/main/java/org/apache/calcite/tools/Frameworks.java
@@ -37,12 +37,12 @@ import org.apache.calcite.sql2rel.SqlToRelConverter;
import org.apache.calcite.sql2rel.StandardConvertletTable;
import org.apache.calcite.util.Util;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.List;
+import java.util.Objects;
import java.util.Properties;
/**
@@ -200,24 +200,23 @@ public class Frameworks {
}
public ConfigBuilder context(Context c) {
- this.context = Preconditions.checkNotNull(c);
+ this.context = Objects.requireNonNull(c);
return this;
}
public ConfigBuilder executor(RexExecutor executor) {
- Preconditions.checkNotNull(executor);
- this.executor = executor;
+ this.executor = Objects.requireNonNull(executor);
return this;
}
public ConfigBuilder convertletTable(
SqlRexConvertletTable convertletTable) {
- this.convertletTable = Preconditions.checkNotNull(convertletTable);
+ this.convertletTable = Objects.requireNonNull(convertletTable);
return this;
}
public ConfigBuilder operatorTable(SqlOperatorTable operatorTable) {
- this.operatorTable = Preconditions.checkNotNull(operatorTable);
+ this.operatorTable = Objects.requireNonNull(operatorTable);
return this;
}
@@ -236,14 +235,14 @@ public class Frameworks {
}
public ConfigBuilder parserConfig(SqlParser.Config parserConfig) {
- this.parserConfig = Preconditions.checkNotNull(parserConfig);
+ this.parserConfig = Objects.requireNonNull(parserConfig);
return this;
}
public ConfigBuilder sqlToRelConverterConfig(
SqlToRelConverter.Config sqlToRelConverterConfig) {
this.sqlToRelConverterConfig =
- Preconditions.checkNotNull(sqlToRelConverterConfig);
+ Objects.requireNonNull(sqlToRelConverterConfig);
return this;
}
@@ -262,7 +261,7 @@ public class Frameworks {
}
public ConfigBuilder ruleSets(List<RuleSet> ruleSets) {
- return programs(Programs.listOf(Preconditions.checkNotNull(ruleSets)));
+ return programs(Programs.listOf(Objects.requireNonNull(ruleSets)));
}
public ConfigBuilder programs(List<Program> programs) {
@@ -276,7 +275,7 @@ public class Frameworks {
}
public ConfigBuilder typeSystem(RelDataTypeSystem typeSystem) {
- this.typeSystem = Preconditions.checkNotNull(typeSystem);
+ this.typeSystem = Objects.requireNonNull(typeSystem);
return this;
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/tools/Programs.java
----------------------------------------------------------------------
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 a37313c..b6337e2 100644
--- a/core/src/main/java/org/apache/calcite/tools/Programs.java
+++ b/core/src/main/java/org/apache/calcite/tools/Programs.java
@@ -64,11 +64,11 @@ import org.apache.calcite.sql2rel.RelDecorrelator;
import org.apache.calcite.sql2rel.RelFieldTrimmer;
import org.apache.calcite.sql2rel.SqlToRelConverter;
-import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -76,13 +76,6 @@ import java.util.List;
* Utilities for creating {@link Program}s.
*/
public class Programs {
- private static final Function<RuleSet, Program> RULE_SET_TO_PROGRAM =
- new Function<RuleSet, Program>() {
- public Program apply(RuleSet ruleSet) {
- return of(ruleSet);
- }
- };
-
public static final ImmutableList<RelOptRule> CALC_RULES =
ImmutableList.of(
NoneToBindableConverterRule.INSTANCE,
@@ -156,12 +149,12 @@ public class Programs {
/** Creates a list of programs based on an array of rule sets. */
public static List<Program> listOf(RuleSet... ruleSets) {
- return Lists.transform(Arrays.asList(ruleSets), RULE_SET_TO_PROGRAM);
+ return Lists.transform(Arrays.asList(ruleSets), Programs::of);
}
/** Creates a list of programs based on a list of rule sets. */
public static List<Program> listOf(List<RuleSet> ruleSets) {
- return Lists.transform(ruleSets, RULE_SET_TO_PROGRAM);
+ return Lists.transform(ruleSets, Programs::of);
}
/** Creates a program from a list of rules. */
@@ -192,26 +185,21 @@ public class Programs {
/** Creates a program that executes a {@link HepProgram}. */
public static Program of(final HepProgram hepProgram, final boolean noDag,
final RelMetadataProvider metadataProvider) {
- return new Program() {
- public RelNode run(RelOptPlanner planner, RelNode rel,
- RelTraitSet requiredOutputTraits,
- List<RelOptMaterialization> materializations,
- List<RelOptLattice> lattices) {
- final HepPlanner hepPlanner = new HepPlanner(hepProgram,
- null, noDag, null, RelOptCostImpl.FACTORY);
-
- List<RelMetadataProvider> list = Lists.newArrayList();
- if (metadataProvider != null) {
- list.add(metadataProvider);
- }
- hepPlanner.registerMetadataProviders(list);
- RelMetadataProvider plannerChain =
- ChainedRelMetadataProvider.of(list);
- rel.getCluster().setMetadataProvider(plannerChain);
-
- hepPlanner.setRoot(rel);
- return hepPlanner.findBestExp();
+ return (planner, rel, requiredOutputTraits, materializations, lattices) -> {
+ final HepPlanner hepPlanner = new HepPlanner(hepProgram,
+ null, noDag, null, RelOptCostImpl.FACTORY);
+
+ List<RelMetadataProvider> list = new ArrayList<>();
+ if (metadataProvider != null) {
+ list.add(metadataProvider);
}
+ hepPlanner.registerMetadataProviders(list);
+ RelMetadataProvider plannerChain =
+ ChainedRelMetadataProvider.of(list);
+ rel.getCluster().setMetadataProvider(plannerChain);
+
+ hepPlanner.setRoot(rel);
+ return hepPlanner.findBestExp();
};
}
@@ -223,45 +211,40 @@ public class Programs {
public static Program heuristicJoinOrder(
final Iterable<? extends RelOptRule> rules,
final boolean bushy, final int minJoinCount) {
- return new Program() {
- public RelNode run(RelOptPlanner planner, RelNode rel,
- RelTraitSet requiredOutputTraits,
- List<RelOptMaterialization> materializations,
- List<RelOptLattice> lattices) {
- final int joinCount = RelOptUtil.countJoins(rel);
- final Program program;
- if (joinCount < minJoinCount) {
- program = ofRules(rules);
- } else {
- // Create a program that gathers together joins as a MultiJoin.
- final HepProgram hep = new HepProgramBuilder()
- .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
- .addMatchOrder(HepMatchOrder.BOTTOM_UP)
- .addRuleInstance(JoinToMultiJoinRule.INSTANCE)
- .build();
- final Program program1 =
- of(hep, false, DefaultRelMetadataProvider.INSTANCE);
-
- // Create a program that contains a rule to expand a MultiJoin
- // into heuristically ordered joins.
- // We use the rule set passed in, but remove JoinCommuteRule and
- // JoinPushThroughJoinRule, because they cause exhaustive search.
- final List<RelOptRule> list = Lists.newArrayList(rules);
- list.removeAll(
- ImmutableList.of(JoinCommuteRule.INSTANCE,
- JoinAssociateRule.INSTANCE,
- JoinPushThroughJoinRule.LEFT,
- JoinPushThroughJoinRule.RIGHT));
- list.add(bushy
- ? MultiJoinOptimizeBushyRule.INSTANCE
- : LoptOptimizeJoinRule.INSTANCE);
- final Program program2 = ofRules(list);
-
- program = sequence(program1, program2);
- }
- return program.run(
- planner, rel, requiredOutputTraits, materializations, lattices);
+ return (planner, rel, requiredOutputTraits, materializations, lattices) -> {
+ final int joinCount = RelOptUtil.countJoins(rel);
+ final Program program;
+ if (joinCount < minJoinCount) {
+ program = ofRules(rules);
+ } else {
+ // Create a program that gathers together joins as a MultiJoin.
+ final HepProgram hep = new HepProgramBuilder()
+ .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
+ .addMatchOrder(HepMatchOrder.BOTTOM_UP)
+ .addRuleInstance(JoinToMultiJoinRule.INSTANCE)
+ .build();
+ final Program program1 =
+ of(hep, false, DefaultRelMetadataProvider.INSTANCE);
+
+ // Create a program that contains a rule to expand a MultiJoin
+ // into heuristically ordered joins.
+ // We use the rule set passed in, but remove JoinCommuteRule and
+ // JoinPushThroughJoinRule, because they cause exhaustive search.
+ final List<RelOptRule> list = Lists.newArrayList(rules);
+ list.removeAll(
+ ImmutableList.of(JoinCommuteRule.INSTANCE,
+ JoinAssociateRule.INSTANCE,
+ JoinPushThroughJoinRule.LEFT,
+ JoinPushThroughJoinRule.RIGHT));
+ list.add(bushy
+ ? MultiJoinOptimizeBushyRule.INSTANCE
+ : LoptOptimizeJoinRule.INSTANCE);
+ final Program program2 = ofRules(list);
+
+ program = sequence(program1, program2);
}
+ return program.run(
+ planner, rel, requiredOutputTraits, materializations, lattices);
};
}
@@ -282,14 +265,8 @@ public class Programs {
}
public static Program getProgram() {
- return new Program() {
- public RelNode run(RelOptPlanner planner, RelNode rel,
- RelTraitSet requiredOutputTraits,
- List<RelOptMaterialization> materializations,
- List<RelOptLattice> lattices) {
- return null;
- }
- };
+ return (planner, rel, requiredOutputTraits, materializations, lattices)
+ -> null;
}
/** Returns the standard program used by Prepare. */
@@ -299,34 +276,28 @@ public class Programs {
/** Returns the standard program with user metadata provider. */
public static Program standard(RelMetadataProvider metadataProvider) {
-
final Program program1 =
- new Program() {
- public RelNode run(RelOptPlanner planner, RelNode rel,
- RelTraitSet requiredOutputTraits,
- List<RelOptMaterialization> materializations,
- List<RelOptLattice> lattices) {
- planner.setRoot(rel);
-
- for (RelOptMaterialization materialization : materializations) {
- planner.addMaterialization(materialization);
- }
- for (RelOptLattice lattice : lattices) {
- planner.addLattice(lattice);
- }
-
- final RelNode rootRel2 =
- rel.getTraitSet().equals(requiredOutputTraits)
- ? rel
- : planner.changeTraits(rel, requiredOutputTraits);
- assert rootRel2 != null;
-
- planner.setRoot(rootRel2);
- final RelOptPlanner planner2 = planner.chooseDelegate();
- final RelNode rootRel3 = planner2.findBestExp();
- assert rootRel3 != null : "could not implement exp";
- return rootRel3;
+ (planner, rel, requiredOutputTraits, materializations, lattices) -> {
+ planner.setRoot(rel);
+
+ for (RelOptMaterialization materialization : materializations) {
+ planner.addMaterialization(materialization);
}
+ for (RelOptLattice lattice : lattices) {
+ planner.addLattice(lattice);
+ }
+
+ final RelNode rootRel2 =
+ rel.getTraitSet().equals(requiredOutputTraits)
+ ? rel
+ : planner.changeTraits(rel, requiredOutputTraits);
+ assert rootRel2 != null;
+
+ planner.setRoot(rootRel2);
+ final RelOptPlanner planner2 = planner.chooseDelegate();
+ final RelNode rootRel3 = planner2.findBestExp();
+ assert rootRel3 != null : "could not implement exp";
+ return rootRel3;
};
return sequence(subQuery(metadataProvider),
@@ -334,8 +305,8 @@ public class Programs {
new TrimFieldsProgram(),
program1,
- // Second planner pass to do physical "tweaks". This the first time that
- // EnumerableCalcRel is introduced.
+ // Second planner pass to do physical "tweaks". This the first time
+ // that EnumerableCalcRel is introduced.
calc(metadataProvider));
}