From 337b9d93f2d6ec7f0fa4755e9eb26a67daa52692 Mon Sep 17 00:00:00 2001 From: Hongze Zhang Date: Fri, 10 Nov 2023 11:21:58 +0800 Subject: [PATCH] [VL] Fix for a corner case may break bhj + exchange validation (#3595) --- .../extension/columnar/TransformHintRule.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gluten-core/src/main/scala/io/glutenproject/extension/columnar/TransformHintRule.scala b/gluten-core/src/main/scala/io/glutenproject/extension/columnar/TransformHintRule.scala index 97b295b5ca42..7bfcd35382c3 100644 --- a/gluten-core/src/main/scala/io/glutenproject/extension/columnar/TransformHintRule.scala +++ b/gluten-core/src/main/scala/io/glutenproject/extension/columnar/TransformHintRule.scala @@ -313,8 +313,10 @@ case class AddTransformHintRule() extends Rule[SparkPlan] { /** Inserts a transformable tag on top of those that are not supported. */ private def addTransformableTags(plan: SparkPlan): SparkPlan = { - addTransformableTag(plan) - plan.withNewChildren(plan.children.map(addTransformableTags)) + // Walk the tree with post-order + val out = plan.withNewChildren(plan.children.map(addTransformableTags)) + addTransformableTag(out) + out } private def addTransformableTag(plan: SparkPlan): Unit = { @@ -551,7 +553,9 @@ case class AddTransformHintRule() extends Rule[SparkPlan] { maybeExchange match { case Some(exchange @ BroadcastExchangeExec(mode, child)) => TransformHints.tag(bhj, isBhjTransformable.toTransformHint) - TransformHints.tagNotTransformable(exchange, isBhjTransformable) + if (!isBhjTransformable.isValid) { + TransformHints.tagNotTransformable(exchange, isBhjTransformable) + } case None => // we are in AQE, find the hidden exchange // FIXME did we consider the case that AQE: OFF && Reuse: ON ?