protected RelNode decorrelateQuery(RelNode rootRel) { return RelDecorrelator.decorrelateQuery(rootRel); }
protected RelNode decorrelateQuery(RelNode rootRel) { RelDecorrelator decorrelator = new RelDecorrelator( rexBuilder, mapRefRelToCorVar, mapCorVarToCorRel, mapFieldAccessToCorVar); boolean dumpPlan = sqlToRelTracer.isLoggable(Level.FINE); RelNode newRootRel = decorrelator.removeCorrelationViaRule(rootRel); if (dumpPlan) { sqlToRelTracer.fine( RelOptUtil.dumpPlan( "Plan after removing CorrelatorRel", newRootRel, false, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); } if (!mapCorVarToCorRel.isEmpty()) { newRootRel = decorrelator.decorrelate(newRootRel); } return newRootRel; }
decorrelateInputWithValueGenerator(rel); newPos, Pair.of( decorrelateExpr(oldProj.get(newPos)), relOutput.get(newPos).getName())); mapOldToNewOutputPos.put(newPos, newPos);
removeCorrelationExpr( pair.left, projectPulledAboveLeftCorrelator,
public void visit(RelNode p, int ordinal, RelNode parent) { // rewrite children first (from left to right) super.visit(p, ordinal, parent); currentRel = p; final String visitMethodName = "decorrelateRel"; boolean found = dispatcher.invokeVisitor( RelDecorrelator.this, currentRel, visitMethodName); setCurrent(null, null); if (!found) { decorrelateRelGeneric(p); } // else no rewrite will occur. This will terminate the bottom-up // rewrite. If root node of a RelNode tree is not rewritten, the // original tree will be returned. See decorrelate() method. } }
createValueGenerator( corVarList, leftChildOutputCount,
newLeftRel, newRightRel, decorrelateExpr(rel.getCondition()), rel.getJoinType(), variablesStopped);
private HepPlanner createPlanner(HepProgram program) { // Create a planner with a hook to update the mapping tables when a // node is copied when it is registered. return new HepPlanner( program, context, true, createCopyHook(), RelOptCostImpl.FACTORY); }
final RexBuilder rexBuilder = cluster.getRexBuilder(); final RelDecorrelator decorrelator = new RelDecorrelator(rexBuilder, corelMap, cluster.getPlanner().getContext()); RelNode newRootRel = decorrelator.removeCorrelationViaRule(rootRel); newRootRel = decorrelator.decorrelate(newRootRel);
decorrelateInputWithValueGenerator(rel); newPos, Pair.of( decorrelateExpr(oldProj.get(newPos)), relOutput.get(newPos).getName())); mapOldToNewOutputPos.put(newPos, newPos);
removeCorrelationExpr( pair.left, projectPulledAboveLeftCorrelator,
public void visit(RelNode p, int ordinal, RelNode parent) { // rewrite children first (from left to right) super.visit(p, ordinal, parent); currentRel = p; final String visitMethodName = "decorrelateRel"; boolean found = dispatcher.invokeVisitor( RelDecorrelator.this, currentRel, visitMethodName); currentRel = null; if (!found) { decorrelateRelGeneric(p); } // else no rewrite will occur. This will terminate the bottom-up // rewrite. If root node of a RelNode tree is not rewritten, the // original tree will be returned. See decorrelate() method. } }
createValueGenerator( corVarList, leftChildOutputCount,
decorrelateInputWithValueGenerator(rel); CalcRel.createFilter( newChildRel, decorrelateExpr(rel.getCondition()));
removeCorrelationExpr( pair.left, projectPulledAboveLeftCorrelator,
protected RelNode decorrelateQuery(RelNode rootRel) { return RelDecorrelator.decorrelateQuery(rootRel); }
decorrelateInputWithValueGenerator(rel); CalcRel.createFilter( newChildRel, decorrelateExpr(rel.getCondition())); newLeftRel, newRightRel, decorrelateExpr(rel.getCondition()), rel.getJoinType(), variablesStopped);
removeCorrelationExpr( pair.left, projectPulledAboveLeftCorrelator,
removeCorrelationExpr(filterRel.getCondition(), false);
correlatedJoinKeys.add((RexFieldAccess) joinKey); RexNode correlatedInputRef = removeCorrelationExpr(joinKey, false); assert correlatedInputRef instanceof RexInputRef; correlatedInputRefJoinKeys.add( removeCorrelationExpr(filterRel.getCondition(), false); } else if (cm.mapRefRelToCorVar.containsKey(aggInputProjRel)) { removeCorrelationExpr(aggInputProjExpr, joinType.generatesNullsOnRight(), nullIndicator)); removeCorrelationExpr(aggOutputProjExprs.get(0), false); newAggOutputProjExprList.add( rexBuilder.makeCast(