Skip to content

Commit

Permalink
[GLUTEN-7143][VL] RAS: Fix fallen back plan nodes are not tagged with…
Browse files Browse the repository at this point in the history
… meaningful fallback reasons (#7731)
  • Loading branch information
zhztheplayer authored Oct 31, 2024
1 parent f7fdf68 commit 40fc52a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ object ExpressionConverter extends SQLConfHelper with Logging {
c)
case c if c.getClass.getSimpleName.equals("CheckOverflowInTableInsert") =>
throw new GlutenNotSupportException(
"CheckOverflowInTableInsert is used in ansi mode, but gluten does not support ANSI mode."
"CheckOverflowInTableInsert is used in ANSI mode, but Gluten does not support ANSI mode."
)
case b: BinaryArithmetic if DecimalArithmeticUtil.isDecimalArithmetic(b) =>
DecimalArithmeticUtil.checkAllowDecimalArithmetic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.gluten.extension.columnar.enumerated

import org.apache.gluten.extension.GlutenPlan
import org.apache.gluten.extension.columnar.OffloadSingleNode
import org.apache.gluten.extension.columnar.{FallbackTags, OffloadSingleNode}
import org.apache.gluten.extension.columnar.rewrite.RewriteSingleNode
import org.apache.gluten.extension.columnar.validator.Validator
import org.apache.gluten.ras.path.Pattern
Expand Down Expand Up @@ -93,16 +93,19 @@ object RasOffload {
// 3. Validate current node. If passed, offload it.
validator.validate(from) match {
case Validator.Passed =>
val offloaded = base.offload(from)
val offloadedNodes = offloaded.collect[GlutenPlan] { case t: GlutenPlan => t }
if (offloadedNodes.exists(!_.doValidate().ok())) {
val offloadedPlan = base.offload(from)
val offloadedNodes = offloadedPlan.collect[GlutenPlan] { case t: GlutenPlan => t }
val outComes = offloadedNodes.map(_.doValidate()).filter(!_.ok())
if (outComes.nonEmpty) {
// 4. If native validation fails on the offloaded node, return the
// original one.
outComes.foreach(FallbackTags.add(from, _))
from
} else {
offloaded
offloadedPlan
}
case Validator.Failed(reason) =>
FallbackTags.add(from, reason)
from
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class GlutenExpressionMappingSuite
sql("create table t2 (b decimal(10,4)) using parquet")

val msg =
"CheckOverflowInTableInsert is used in ansi mode, but gluten does not support ANSI mode."
"CheckOverflowInTableInsert is used in ANSI mode, but Gluten does not support ANSI mode."
import org.apache.spark.sql.execution.GlutenImplicits._
val fallbackSummary = sql("insert overwrite t2 select * from t1").fallbackSummary
val fallbackSummary = sql("insert overwrite t2 select * from t1").fallbackSummary()
assert(fallbackSummary.fallbackNodeToReason.flatMap(_.values).exists(_.contains(msg)))
}
}
Expand Down

0 comments on commit 40fc52a

Please sign in to comment.