minni31 commented on code in PR #12766: URL: https://github.com/apache/gluten/pull/12766#discussion_r3796883048
########## gluten-substrait/src/main/scala/org/apache/spark/sql/execution/EmptyRelationExecTransformer.scala: ########## @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.execution + +import org.apache.gluten.backendsapi.BackendsApiManager +import org.apache.gluten.execution.{ValidatablePlan, ValidationResult} +import org.apache.gluten.extension.columnar.transition.Convention + +import org.apache.spark.rdd.RDD +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.catalyst.expressions.Attribute +import org.apache.spark.sql.vectorized.ColumnarBatch + +/** + * Columnar-aware replacement for Spark's EmptyRelationExec (Spark 4.0+). It produces an empty + * RDD[ColumnarBatch] so that surrounding columnar operators do not need to be wrapped in + * unnecessary ColumnarToRow / RowToColumnar transitions when AQE propagates an empty relation + * through the plan. + */ +case class EmptyRelationExecTransformer(output: Seq[Attribute]) + extends LeafExecNode Review Comment: Thanks @weiting-chen — great point, done in `ba8302e12`. The transformer now extends `GlutenPlan` instead of `ValidatablePlan`, so it no longer goes through `FallbackByNativeValidation` (which only validates `ValidatablePlan` nodes) — native schema validation is irrelevant for a leaf that never sends data to Velox, and this removes the spurious fallback when the unused output schema has a backend-unsupported type. It's now genuinely dual-mode: `rowType() = VanillaRowType` + `batchType() = primaryBatchType`, with both `doExecute` → `emptyRDD[InternalRow]` and `doExecuteColumnar` → `emptyRDD[ColumnarBatch]` implemented. So a row consumer reads it directly (no terminal C2R) and a columnar consumer reads the empty batch RDD — the transition framework picks either with zero transitions. I verified `ConventionFunc.checkRowType`/`checkBatchType` stay consistent since `GlutenPlan` derives `supportsRowBased`/`supportsColumnar` from these (both non-`None`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
