Indian-boult opened a new issue, #1026:
URL: https://github.com/apache/incubator-xtable/issues/1026

   When an Iceberg source table has position deletes, equality deletes or 
deletion vectors, XTable syncs its data files as if every row in them were 
still live. The targets return rows that the source has deleted, and every sync 
reports SUCCESS.
   
   ### Reproduction
   
   I reproduced this on main at 77ecf22 with Spark 3.4.2 and Iceberg 1.9.2. 
Each case starts from a table that was already synced to Delta and Hudi, makes 
one change in Iceberg, runs one more sync and counts rows with Spark. The 
equality delete is committed with the Java `RowDelta` API, and the other 
changes are Spark SQL.
   
   ```sql
   CREATE TABLE t (id INT, name STRING) USING iceberg
     TBLPROPERTIES ('format-version'='2', 'write.delete.mode'='merge-on-read', 
'write.update.mode'='merge-on-read');
   INSERT INTO t SELECT id, CAST(id AS STRING) FROM range(100);
   -- sync to DELTA and HUDI, then
   DELETE FROM t WHERE id < 10;
   -- sync again and count the rows in each format
   ```
   
   | Change in the Iceberg source | Iceberg | Delta | Hudi |
   |---|---|---|---|
   | v2 merge-on-read `DELETE WHERE id < 10` on 100 rows | 90 | 100 | 100 |
   | merge-on-read `UPDATE` of 5 rows after that | 90 | 105 | 105 |
   | equality delete of 5 ids on 50 rows, the way Flink upserts write them | 45 
| 50 | 50 |
   | v3 table, `DELETE WHERE id < 10`, written as a deletion vector | 90 | 100 
| 100 |
   
   The extra rows in the targets are exactly the deleted ids, and after the 
UPDATE both the old and the new version of each updated row are visible. A FULL 
sync into a fresh target gives the same counts.
   
   ### Cause
   
   `IcebergConversionSource.getCurrentSnapshot` reads only 
`FileScanTask.file()` and never looks at `FileScanTask.deletes()`. 
`getTableChangeForCommit` reads only `snapshot.addedDataFiles` and 
`snapshot.removedDataFiles`, so a merge-on-read DELETE commit, which adds only 
delete files, becomes an empty diff. The docs say delete vectors are not 
captured, but nothing warns at runtime.
   
   ### Proposal
   
   Fail closed, the same way #938 does for Delta deletion vectors in #657.
   
   1. A full sync fails when any delete file applies to a data file in the 
current snapshot. The scan already joins the delete manifests, so the check 
reads nothing extra.
   2. An incremental sync fails on a commit whose `addedDeleteFiles` is not 
empty. This reads only the delete manifests that the commit wrote, so commits 
without deletes cost nothing extra.
   3. `getCommitsBacklog` stays as it is, following the review on #938 that 
took the snapshot scan out of incremental sync. The docs say that targets 
synced from such a table by an earlier release need a full rebuild.
   4. Setting the source property 
`xtable.iceberg.source.allow_unsupported_delete_files=true` logs one warning 
and keeps the current behavior.
   
   Converting the deletes into Delta deletion vectors is the larger piece 
tracked in #341, #346 and #347, and this does not take it over. It stops the 
silent corruption until that lands. Equality deletes would still need this 
check after that, because turning them into row positions means reading the 
data files.
   
   I have a patch with tests and will open a PR. The property name is open. I 
used an Iceberg key next to the Delta key from #938, and a single key for all 
source formats would work as well.
   


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

Reply via email to