diff --git a/native-sql-engine/core/src/main/scala/org/apache/spark/sql/execution/ColumnarCollapseCodegenStages.scala b/native-sql-engine/core/src/main/scala/org/apache/spark/sql/execution/ColumnarCollapseCodegenStages.scala index e358672d3..176566fb6 100644 --- a/native-sql-engine/core/src/main/scala/org/apache/spark/sql/execution/ColumnarCollapseCodegenStages.scala +++ b/native-sql-engine/core/src/main/scala/org/apache/spark/sql/execution/ColumnarCollapseCodegenStages.scala @@ -156,7 +156,8 @@ case class ColumnarCollapseCodegenStages( if (containsSubquery(p.condition) || containsSubquery(p.projectList)) => false case p: ColumnarCodegenSupport if p.supportColumnarCodegen => - plan.children.map(existsJoins(_, count)).exists(_ == true) + if (count >= 1) true + else plan.children.map(existsJoins(_, count)).exists(_ == true) case _ => false }