aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec
diff options
context:
space:
mode:
authorVolodymyr Vysotskyi <vvovyk@gmail.com>2017-12-13 14:53:47 +0200
committerVolodymyr Vysotskyi <vvovyk@gmail.com>2018-01-16 12:10:13 +0200
commit688e043b4546884d82422b266b419817d645acfc (patch)
treea662ec009c394daaf2f93514ef1b8bcea38d227e /exec/java-exec
parentd59f0cda481d98a15d11ecbfb1463db53c954dfb (diff)
DRILL-3993: Move Drill-specific commits 'CALCITE-628' and 'Drill-specific change: Add back AbstractConverter in RelSet.java' from Calcite into DRILL
Diffstat (limited to 'exec/java-exec')
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRule.java4
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillUnionAllRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prel.java29
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SortConvertPrule.java8
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java2
12 files changed, 34 insertions, 25 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRule.java
index 70f221512..2b998b290 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRule.java
@@ -54,7 +54,7 @@ public class DrillAggregateRule extends RelOptRule {
}
final RelTraitSet traits = aggregate.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
- final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
try {
call.transformTo(new DrillAggregateRel(aggregate.getCluster(), traits, convertedInput, aggregate.indicator,
aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList()));
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java
index f3769f001..54808303e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java
@@ -38,7 +38,7 @@ public class DrillFilterRule extends RelOptRule {
public void onMatch(RelOptRuleCall call) {
final LogicalFilter filter = call.rel(0);
final RelNode input = filter.getInput();
- final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
call.transformTo(new DrillFilterRel(
filter.getCluster(), convertedInput.getTraitSet(),
convertedInput, filter.getCondition()));
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRule.java
index 766509e54..1ad41a215 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRule.java
@@ -58,8 +58,8 @@ public class DrillJoinRule extends RelOptRule {
final RelNode right = join.getRight();
final RelTraitSet traits = join.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
- final RelNode convertedLeft = convert(left, left.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
- final RelNode convertedRight = convert(right, right.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ final RelNode convertedLeft = convert(left, left.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
+ final RelNode convertedRight = convert(right, right.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
List<Integer> leftKeys = Lists.newArrayList();
List<Integer> rightKeys = Lists.newArrayList();
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRule.java
index 6d2da9ddb..cac24f01c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRule.java
@@ -54,7 +54,7 @@ public class DrillLimitRule extends RelOptRule {
input = incomingSort.copy(incomingTraits, input, incomingSort.getCollation(), null, null);
}
- RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
call.transformTo(new DrillLimitRel(
incomingSort.getCluster(), convertedInput.getTraitSet().plus(DrillRel.DRILL_LOGICAL),
convertedInput, incomingSort.offset, incomingSort.fetch));
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRule.java
index 14c653380..c38a626a2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRule.java
@@ -41,7 +41,7 @@ public class DrillProjectRule extends RelOptRule {
final Project project = call.rel(0);
final RelNode input = project.getInput();
final RelTraitSet traits = project.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
- final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
call.transformTo(new DrillProjectRel(
project.getCluster(), traits, convertedInput, project.getProjects(), project.getRowType()));
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRule.java
index 1ab061ba8..390ae1e0c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRule.java
@@ -49,7 +49,7 @@ public class DrillSortRule extends RelOptRule {
final RelNode input = sort.getInput();
final RelTraitSet traits = sort.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
- final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
call.transformTo(new DrillSortRel(sort.getCluster(), traits, convertedInput, sort.getCollation()));
}
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillUnionAllRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillUnionAllRule.java
index 91697a28d..df9d05af7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillUnionAllRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillUnionAllRule.java
@@ -55,7 +55,7 @@ public class DrillUnionAllRule extends RelOptRule {
final RelTraitSet traits = union.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
final List<RelNode> convertedInputs = new ArrayList<>();
for (RelNode input : union.getInputs()) {
- final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
+ final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
convertedInputs.add(convertedInput);
}
try {
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
index 4461796e4..3c3ac6e22 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
@@ -37,7 +37,7 @@ public class DrillWindowRule extends RelOptRule {
public void onMatch(RelOptRuleCall call) {
final Window window = call.rel(0);
final RelNode input = call.rel(1);
- final RelTraitSet traits = window.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
+ final RelTraitSet traits = window.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify();
final RelNode convertedInput = convert(input, traits);
call.transformTo(
new DrillWindowRel(
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prel.java
index db370408b..77794d05e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prel.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -20,31 +20,38 @@ package org.apache.drill.exec.planner.physical;
import java.io.IOException;
import org.apache.calcite.plan.Convention;
+import org.apache.calcite.plan.RelTraitSet;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.planner.common.DrillRelNode;
import org.apache.drill.exec.planner.physical.visitor.PrelVisitor;
import org.apache.drill.exec.record.BatchSchema.SelectionVectorMode;
-public interface Prel extends DrillRelNode, Iterable<Prel>{
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Prel.class);
+public interface Prel extends DrillRelNode, Iterable<Prel> {
+ org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Prel.class);
- final static Convention DRILL_PHYSICAL = new Convention.Impl("PHYSICAL", Prel.class);
+ Convention DRILL_PHYSICAL = new Convention.Impl("PHYSICAL", Prel.class) {
+ public boolean canConvertConvention(Convention toConvention) {
+ return true;
+ }
- public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException;
+ public boolean useAbstractConvertersForConversion(RelTraitSet fromTraits,
+ RelTraitSet toTraits) {
+ return true;
+ }
+ };
- public <T, X, E extends Throwable> T accept(PrelVisitor<T, X, E> logicalVisitor, X value) throws E;
+ PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException;
+
+ <T, X, E extends Throwable> T accept(PrelVisitor<T, X, E> logicalVisitor, X value) throws E;
/**
* Supported 'encodings' of a Prel indicates what are the acceptable modes of SelectionVector
* of its child Prel
*/
- public SelectionVectorMode[] getSupportedEncodings();
+ SelectionVectorMode[] getSupportedEncodings();
/**
* A Prel's own SelectionVector mode - i.e whether it generates an SV2, SV4 or None
*/
- public SelectionVectorMode getEncoding();
+ SelectionVectorMode getEncoding();
boolean needsFinalColumnReordering();
-
- // DRILL-3011
- // public abstract Prel copy(RelTraitSet paramRelTraitSet, List<RelNode> paramList);
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prule.java
index 148e74b18..28d8dabea 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prule.java
@@ -41,7 +41,7 @@ public abstract class Prule extends RelOptRule {
toTraits = toTraits.replace(DrillDistributionTrait.ANY);
}
- return RelOptRule.convert(rel, toTraits);
+ return RelOptRule.convert(rel, toTraits.simplify());
}
public static boolean isSingleMode(RelOptRuleCall call) {
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SortConvertPrule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SortConvertPrule.java
index e13c550c2..714262df9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SortConvertPrule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SortConvertPrule.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.planner.physical;
+import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Sort;
import org.apache.calcite.rel.convert.ConverterRule;
@@ -47,9 +48,10 @@ public class SortConvertPrule extends ConverterRule {
@Override
public RelNode convert(RelNode r) {
Sort rel = (Sort) r;
+ RelTraitSet traits = rel.getInput().getTraitSet().replace(Prel.DRILL_PHYSICAL);
return new SortPrel(rel.getCluster(),
- rel.getInput().getTraitSet().replace(Prel.DRILL_PHYSICAL).plus(rel.getCollation()),
- convert(rel.getInput(), rel.getInput().getTraitSet().replace(Prel.DRILL_PHYSICAL)),
+ traits.plus(rel.getCollation()),
+ convert(rel.getInput(), traits.simplify()),
rel.getCollation());
}
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java
index 03283b138..3562d5cb0 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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