aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical
diff options
context:
space:
mode:
authorHanumathRao <hanu.ncr@gmail.com>2018-06-21 18:42:24 -0700
committerVolodymyr Vysotskyi <vvovyk@gmail.com>2018-07-01 19:06:29 +0300
commit8ec2dc64175648103a5ec51f8ad98387496692a9 (patch)
tree7ec2cf94373d1a8165f954efb28cbb017a3b172f /exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical
parent7c22e35ef2a9ecc41cc15c5deefac9b306ea87a1 (diff)
DRILL-6545: Projection Push down into Lateral Join operator.
closes #1347
Diffstat (limited to 'exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical')
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrel.java40
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrule.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/JoinPrelRenameVisitor.java2
3 files changed, 35 insertions, 9 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrel.java
index 565871bb2..b55076bd0 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrel.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.RelWriter;
import org.apache.calcite.rel.core.Correlate;
import org.apache.calcite.rel.core.CorrelationId;
import org.apache.calcite.rel.type.RelDataType;
@@ -30,6 +31,8 @@ import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.sql.SemiJoinType;
import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.commons.collections.ListUtils;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.physical.config.LateralJoinPOP;
import org.apache.drill.exec.planner.common.DrillLateralJoinRelBase;
@@ -38,21 +41,23 @@ import org.apache.drill.exec.planner.physical.visitor.PrelVisitor;
import org.apache.drill.exec.record.BatchSchema;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class LateralJoinPrel extends DrillLateralJoinRelBase implements Prel {
- protected LateralJoinPrel(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right,
+ protected LateralJoinPrel(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, boolean excludeCorrelateCol,
CorrelationId correlationId, ImmutableBitSet requiredColumns, SemiJoinType semiJoinType) {
- super(cluster, traits, left, right, correlationId, requiredColumns, semiJoinType);
+ super(cluster, traits, left, right, excludeCorrelateCol, correlationId, requiredColumns, semiJoinType);
}
+
@Override
public Correlate copy(RelTraitSet traitSet,
RelNode left, RelNode right, CorrelationId correlationId,
ImmutableBitSet requiredColumns, SemiJoinType joinType) {
- return new LateralJoinPrel(this.getCluster(), this.getTraitSet(), left, right, correlationId, requiredColumns,
+ return new LateralJoinPrel(this.getCluster(), this.getTraitSet(), left, right, this.excludeCorrelateColumn, correlationId, requiredColumns,
this.getJoinType());
}
@@ -63,11 +68,22 @@ public class LateralJoinPrel extends DrillLateralJoinRelBase implements Prel {
PhysicalOperator rightPop = ((Prel)right).getPhysicalOperator(creator);
SemiJoinType jtype = this.getJoinType();
-
- LateralJoinPOP ljoin = new LateralJoinPOP(leftPop, rightPop, jtype.toJoinType());
+ List<SchemaPath> excludedColumns = new ArrayList<>();
+ if (getColumn() != null) {
+ excludedColumns.add(getColumn());
+ }
+ LateralJoinPOP ljoin = new LateralJoinPOP(leftPop, rightPop, jtype.toJoinType(), excludedColumns);
return creator.addMetadata(this, ljoin);
}
+ private SchemaPath getColumn() {
+ if (this.excludeCorrelateColumn) {
+ int index = this.getRequiredColumns().asList().get(0);
+ return SchemaPath.getSimplePath(this.getInput(0).getRowType().getFieldNames().get(index));
+ }
+ return null;
+ }
+
/**
* Check to make sure that the fields of the inputs are the same as the output field names.
* If not, insert a project renaming them.
@@ -76,8 +92,8 @@ public class LateralJoinPrel extends DrillLateralJoinRelBase implements Prel {
Preconditions.checkArgument(DrillJoinRelBase.uniqueFieldNames(input.getRowType()));
final List<String> fields = getRowType().getFieldNames();
final List<String> inputFields = input.getRowType().getFieldNames();
- final List<String> outputFields = fields.subList(offset, offset + inputFields.size());
- if (!outputFields.equals(inputFields)) {
+ final List<String> outputFields = fields.subList(offset, offset + getInputSize(offset, input));
+ if (ListUtils.subtract(outputFields, inputFields).size() != 0) {
// Ensure that input field names are the same as output field names.
// If there are duplicate field names on left and right, fields will get
// lost.
@@ -105,6 +121,16 @@ public class LateralJoinPrel extends DrillLateralJoinRelBase implements Prel {
}
@Override
+ public RelWriter explainTerms(RelWriter pw) {
+ if (this.excludeCorrelateColumn) {
+ return super.explainTerms(pw).item("column excluded from output: ", this.getColumn());
+ } else {
+ return super.explainTerms(pw);
+ }
+ }
+
+
+ @Override
public <T, X, E extends Throwable> T accept(PrelVisitor<T, X, E> visitor, X value) throws E {
return visitor.visitLateral(this, value);
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrule.java
index e531dca4a..10e247b01 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/LateralJoinPrule.java
@@ -48,7 +48,7 @@ public class LateralJoinPrule extends Prule {
final LateralJoinPrel lateralJoinPrel = new LateralJoinPrel(lateralJoinRel.getCluster(),
corrTraits,
- convertedLeft, convertedRight, lateralJoinRel.getCorrelationId(),
+ convertedLeft, convertedRight, lateralJoinRel.excludeCorrelateColumn, lateralJoinRel.getCorrelationId(),
lateralJoinRel.getRequiredColumns(),lateralJoinRel.getJoinType());
call.transformTo(lateralJoinPrel);
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/JoinPrelRenameVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/JoinPrelRenameVisitor.java
index d450c5616..850f0bdf0 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/JoinPrelRenameVisitor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/JoinPrelRenameVisitor.java
@@ -76,7 +76,7 @@ public class JoinPrelRenameVisitor extends BasePrelVisitor<Prel, Void, RuntimeEx
List<RelNode> children = getChildren(prel);
- final int leftCount = children.get(0).getRowType().getFieldCount();
+ final int leftCount = prel.getInputSize(0,children.get(0));
List<RelNode> reNamedChildren = Lists.newArrayList();