diff --git a/backends-velox/src/main/scala/org/apache/gluten/extension/PartialProjectRule.scala b/backends-velox/src/main/scala/org/apache/gluten/extension/PartialProjectRule.scala index 066f09d75e53..73d1651e2fdb 100644 --- a/backends-velox/src/main/scala/org/apache/gluten/extension/PartialProjectRule.scala +++ b/backends-velox/src/main/scala/org/apache/gluten/extension/PartialProjectRule.scala @@ -27,12 +27,12 @@ case class PartialProjectRule(spark: SparkSession) extends Rule[SparkPlan] { plan.transformUp { case plan: ProjectExec => val transformer = ColumnarPartialProjectExec.create(plan) - if (transformer.doValidate().ok()) { - if (transformer.child.asInstanceOf[ColumnarPartialProjectExec].doValidate().ok()) { - transformer - } else plan + if ( + transformer.doValidate().ok() && + transformer.child.asInstanceOf[ColumnarPartialProjectExec].doValidate().ok() + ) { + transformer } else plan - case p => p } } }