DRILL-3993: Move Drill-specific commits 'CALCITE-628' and 'Drill-specific change: Add back AbstractConverter in RelSet.java' from Calcite into DRILL
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/688e043b Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/688e043b Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/688e043b Branch: refs/heads/master Commit: 688e043b4546884d82422b266b419817d645acfc Parents: d59f0cd Author: Volodymyr Vysotskyi <vvo...@gmail.com> Authored: Wed Dec 13 14:53:47 2017 +0200 Committer: Volodymyr Vysotskyi <vvo...@gmail.com> Committed: Tue Jan 16 12:10:13 2018 +0200 ---------------------------------------------------------------------- .../exec/store/jdbc/DrillJdbcRuleBase.java | 4 +-- .../exec/store/jdbc/JdbcStoragePlugin.java | 2 +- .../planner/logical/DrillAggregateRule.java | 2 +- .../exec/planner/logical/DrillFilterRule.java | 2 +- .../exec/planner/logical/DrillJoinRule.java | 4 +-- .../exec/planner/logical/DrillLimitRule.java | 2 +- .../exec/planner/logical/DrillProjectRule.java | 2 +- .../exec/planner/logical/DrillSortRule.java | 2 +- .../exec/planner/logical/DrillUnionAllRule.java | 2 +- .../exec/planner/logical/DrillWindowRule.java | 2 +- .../drill/exec/planner/physical/Prel.java | 29 ++++++++++++-------- .../drill/exec/planner/physical/Prule.java | 2 +- .../exec/planner/physical/SortConvertPrule.java | 8 ++++-- .../planner/physical/SubsetTransformer.java | 2 +- 14 files changed, 37 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/DrillJdbcRuleBase.java ---------------------------------------------------------------------- diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/DrillJdbcRuleBase.java b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/DrillJdbcRuleBase.java index 963e80a..9d29a22 100644 --- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/DrillJdbcRuleBase.java +++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/DrillJdbcRuleBase.java @@ -65,7 +65,7 @@ abstract class DrillJdbcRuleBase extends ConverterRule { public RelNode convert(RelNode rel) { LogicalProject project = (LogicalProject) rel; return new JdbcRules.JdbcProject(rel.getCluster(), rel.getTraitSet().replace(this.out), convert( - project.getInput(), project.getInput().getTraitSet().replace(this.out)), project.getProjects(), + project.getInput(), project.getInput().getTraitSet().replace(this.out).simplify()), project.getProjects(), project.getRowType()); } @@ -97,7 +97,7 @@ abstract class DrillJdbcRuleBase extends ConverterRule { LogicalFilter filter = (LogicalFilter) rel; return new JdbcRules.JdbcFilter(rel.getCluster(), rel.getTraitSet().replace(this.out), convert(filter.getInput(), - filter.getInput().getTraitSet().replace(this.out)), filter.getCondition()); + filter.getInput().getTraitSet().replace(this.out).simplify()), filter.getCondition()); } @Override http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java ---------------------------------------------------------------------- diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java index 4b41696..47f0f21 100755 --- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java +++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java @@ -230,7 +230,7 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin { @Override public RelNode convert(RelNode in) { return new JdbcDrel(in.getCluster(), in.getTraitSet().replace(DrillRel.DRILL_LOGICAL), - convert(in, in.getTraitSet().replace(this.getInTrait()))); + convert(in, in.getTraitSet().replace(this.getInTrait()).simplify())); } } http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRule.java ---------------------------------------------------------------------- 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 70f2215..2b998b2 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())); http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java ---------------------------------------------------------------------- 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 f3769f0..5480830 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())); http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRule.java ---------------------------------------------------------------------- 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 766509e..1ad41a2 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(); http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRule.java ---------------------------------------------------------------------- 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 6d2da9d..cac24f0 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)); http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRule.java ---------------------------------------------------------------------- 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 14c6533..c38a626 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())); } http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRule.java ---------------------------------------------------------------------- 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 1ab061b..390ae1e 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())); } } http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillUnionAllRule.java ---------------------------------------------------------------------- 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 91697a2..df9d05a 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 { http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java ---------------------------------------------------------------------- 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 4461796..3c3ac6e 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( http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prel.java ---------------------------------------------------------------------- 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 db37040..77794d0 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); } http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/Prule.java ---------------------------------------------------------------------- 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 148e74b..28d8dab 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) { http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SortConvertPrule.java ---------------------------------------------------------------------- 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 e13c550..714262d 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()); } } http://git-wip-us.apache.org/repos/asf/drill/blob/688e043b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java ---------------------------------------------------------------------- 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 03283b1..3562d5c 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