Skip to content

Commit

Permalink
[CORE] Rename isTransformable API to maybeTransformable (#6233)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyangxiaozhu authored Jun 28, 2024
1 parent 22dc4fd commit b6776b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,15 @@ case class OffloadFilter() extends OffloadSingleNode with LogLevelUtil {
// Push down the left conditions in Filter into FileSourceScan.
val newChild: SparkPlan = filter.child match {
case scan @ (_: FileSourceScanExec | _: BatchScanExec) =>
if (TransformHints.isTransformable(scan)) {
if (TransformHints.maybeTransformable(scan)) {
val newScan =
FilterHandler.pushFilterToScan(filter.condition, scan)
newScan match {
case ts: TransformSupport if ts.doValidate().isValid => ts
// TODO remove the call
case _ => replace.doReplace(scan)
case _ => scan
}
} else {
replace.doReplace(scan)
}
case _ => replace.doReplace(filter.child)
} else scan
case _ => filter.child
}
logDebug(s"Columnar Processing for ${filter.getClass} is currently supported.")
BackendsApiManager.getSparkPlanExecApiInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,12 @@ object TransformHints {
}

/**
* NOTE: To be deprecated. Do not create new usages of this method.
*
* Since it's usually not safe to consider a plan "transformable" during validation phase. Another
* validation rule could turn "transformable" to "non-transformable" before implementing the plan
* within Gluten transformers.
* If true, it implies the plan maybe transformable during validation phase but not guaranteed,
* since another validation rule could turn it to "non-transformable" before implementing the plan
* within Gluten transformers. If false, the plan node will be guaranteed fallback to Vanilla plan
* node while being implemented.
*/
def isTransformable(plan: SparkPlan): Boolean = {
getHintOption(plan) match {
case None => true
case _ => false
}
}
def maybeTransformable(plan: SparkPlan): Boolean = !isNotTransformable(plan)

def tag(plan: SparkPlan, hint: TransformHint): Unit = {
val mergedHint = getHintOption(plan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RewriteSparkPlanRulesManager private (rewriteRules: Seq[RewriteSingleNode]
extends Rule[SparkPlan] {

private def mayNeedRewrite(plan: SparkPlan): Boolean = {
TransformHints.isTransformable(plan) && {
TransformHints.maybeTransformable(plan) && {
plan match {
case _: SortExec => true
case _: TakeOrderedAndProjectExec => true
Expand Down

0 comments on commit b6776b6

Please sign in to comment.