diff --git a/gluten-core/src/main/scala/org/apache/gluten/extension/columnar/enumerated/RasOffload.scala b/gluten-core/src/main/scala/org/apache/gluten/extension/columnar/enumerated/RasOffload.scala index 6af89dc057aa..8091127da0bf 100644 --- a/gluten-core/src/main/scala/org/apache/gluten/extension/columnar/enumerated/RasOffload.scala +++ b/gluten-core/src/main/scala/org/apache/gluten/extension/columnar/enumerated/RasOffload.scala @@ -105,13 +105,13 @@ object RasOffload { validator.validate(from) match { case Validator.Passed => val offloaded = base.offload(from) - offloaded match { - case t: GlutenPlan if !t.doValidate().isValid => - // 4. If native validation fails on the offloaded node, return the - // original one. - from - case other => - other + val offloadedNodes = offloaded.collect[GlutenPlan] { case t: GlutenPlan => t } + if (offloadedNodes.exists(!_.doValidate().isValid)) { + // 4. If native validation fails on the offloaded node, return the + // original one. + from + } else { + offloaded } case Validator.Failed(reason) => from