sunchao commented on code in PR #6587:
URL: https://github.com/apache/datafusion-comet/pull/6587#discussion_r4176791432


##########
spark/src/main/spark-4.2/org/apache/spark/sql/comet/IcebergTransactionalCommitExec.scala:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.transactions.TransactionUtils
+import org.apache.spark.sql.connector.catalog.transactions.Transaction
+import org.apache.spark.sql.execution.SparkPlan
+import org.apache.spark.sql.execution.datasources.v2.TransactionalExec
+
+/** Spark 4.2 transaction-aware view of Comet's driver-side Iceberg commit 
node. */
+private[org] final class IcebergTransactionalCommitExec private (
+    delegate: IcebergCommitExec,
+    override val transaction: Option[Transaction])
+    extends IcebergCommitExec(
+      delegate.batchWrite,
+      delegate.write,
+      delegate.refreshCache,
+      delegate.child)
+    with TransactionalExec {
+
+  override def withTransaction(txn: Option[Transaction]): SparkPlan = 
copyWith(transaction = txn)

Review Comment:
   [P2] Include `transaction` in the node’s equality contract. For a Spark 4.2 
split Iceberg write with an active catalog transaction, 
`QueryExecution.attachTransaction` calls this method through 
`plan.transformDown`. The returned copy inherits `IcebergCommitExec.equals`, 
which compares only the four parent fields, so it equals the original node 
despite carrying `Some(txn)`. Spark consequently discards the copy and retains 
`transaction=None`. The new hook never commits or closes the transaction, 
allowing the write to report success without publishing transaction-staged 
changes. Could this use transaction-aware `equals`/`canEqual`/`hashCode`, or a 
plan representation that includes the transaction, with a regression covering 
Spark’s attachment transformation?
   
   Evidence: Spark v4.2.0 QueryExecution.scala:637–640 attaches transactions 
using `transformDown`; TreeNode.scala:498–505 retains the original when 
`fastEquals` succeeds. Running `/tmp/comet-6587-review/run-probe.py` with the 
exact-head commit classes produced `direct_transaction_present=true`, 
`initial_fastEquals_direct=true`, `transformed_is_original=true`, and 
`transformed_transaction=None`. Direct clone, makeCopy and child-replacement 
checks preserved the transaction. Repeating the probe with transaction-aware 
equality in a disposable source copy produced `initial_fastEquals_direct=false` 
and retained `Some(txn)`. The added PR test checks the class name without 
attaching a transaction, so it does not exercise this failure.



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