@@ -454,7 +454,7 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]]
454454 * to rewrite the whole plan, include its subqueries, in one go.
455455 */
456456 def transformWithSubqueries (f : PartialFunction [PlanType , PlanType ]): PlanType =
457- transformDownWithSubqueries(AlwaysProcess .fn, UnknownRuleId )( f)
457+ transformDownWithSubqueries(f)
458458
459459 /**
460460 * Returns a copy of this node where the given partial function has been recursively applied
@@ -479,18 +479,28 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]]
479479 * first to this node, then this node's subqueries and finally this node's children.
480480 * When the partial function does not apply to a given node, it is left unchanged.
481481 */
482- def transformDownWithSubqueries (
483- cond : TreePatternBits => Boolean = AlwaysProcess .fn, ruleId : RuleId = UnknownRuleId )
484- (f : PartialFunction [PlanType , PlanType ])
485- : PlanType = {
482+ def transformDownWithSubqueries (f : PartialFunction [PlanType , PlanType ]): PlanType = {
483+ transformDownWithSubqueriesAndPruning(AlwaysProcess .fn, UnknownRuleId )(f)
484+ }
485+
486+ /**
487+ * This method is the top-down (pre-order) counterpart of transformUpWithSubqueries.
488+ * Returns a copy of this node where the given partial function has been recursively applied
489+ * first to this node, then this node's subqueries and finally this node's children.
490+ * When the partial function does not apply to a given node, it is left unchanged.
491+ */
492+ def transformDownWithSubqueriesAndPruning (
493+ cond : TreePatternBits => Boolean ,
494+ ruleId : RuleId = UnknownRuleId )
495+ (f : PartialFunction [PlanType , PlanType ]): PlanType = {
486496 val g : PartialFunction [PlanType , PlanType ] = new PartialFunction [PlanType , PlanType ] {
487497 override def isDefinedAt (x : PlanType ): Boolean = true
488498
489499 override def apply (plan : PlanType ): PlanType = {
490500 val transformed = f.applyOrElse[PlanType , PlanType ](plan, identity)
491501 transformed transformExpressionsDown {
492502 case planExpression : PlanExpression [PlanType ] =>
493- val newPlan = planExpression.plan.transformDownWithSubqueries (cond, ruleId)(f)
503+ val newPlan = planExpression.plan.transformDownWithSubqueriesAndPruning (cond, ruleId)(f)
494504 planExpression.withNewPlan(newPlan)
495505 }
496506 }
0 commit comments