jeffw13 commented on code in PR #5821:
URL: https://github.com/apache/datafusion-comet/pull/5821#discussion_r4009110950


##########
spark/src/main/scala/org/apache/comet/serde/operator/CometDataWritingCommand.scala:
##########
@@ -59,6 +62,14 @@ object CometDataWritingCommand extends 
CometOperatorSerde[DataWritingCommandExec
       case cmd: InsertIntoHadoopFsRelationCommand =>
         cmd.fileFormat match {
           case _: ParquetFileFormat =>
+            // AQE can replace the write input with a zero-partition empty 
relation. Keep
+            // Spark's writer, which creates an empty task to preserve the 
output file schema.
+            // The native writer only maps existing partitions and cannot do 
that yet.
+            if (hasEmptyRelationInput(op.child)) {

Review Comment:
   Yes, I've documented the trade-off we're making here further (that an empty 
relation could ultimately produce a non zero-partition count) more and linked 
to that open issue.



##########
docs/source/user-guide/latest/compatibility/operators.md:
##########
@@ -19,6 +19,19 @@ under the License.
 
 # Operator Compatibility
 
+## Empty Relations

Review Comment:
   I've added this documentation + the spark version note in 
https://github.com/apache/datafusion-comet/pull/5821/changes/1296afd34d6caa8e19b53bd7b6d7ef3e8fcac441
 



##########
spark/src/main/spark-4.x/org/apache/spark/sql/comet/shims/ShimCometEmptyRelation.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.comet.shims
+
+import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
+import org.apache.spark.sql.execution.{EmptyRelationExec, SparkPlan}
+
+/** EmptyRelationExec is available starting in Spark 4.0. */
+object ShimCometEmptyRelation {
+
+  def emptyRelationClass: Option[Class[_ <: SparkPlan]] = 
Some(classOf[EmptyRelationExec])
+
+  def create(logical: LogicalPlan): Option[SparkPlan] = 
Some(EmptyRelationExec(logical))

Review Comment:
   Yes, this makes sense. I've moved them over to the spark-4.x location and 
registered them, and removed the version conditional. I also split them into 
three separate test suites.



-- 
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]

Reply via email to