kccrcodes commented on issue #19117: URL: https://github.com/apache/iceberg/issues/19117#issuecomment-7150621016
Hello, I would like to pick this up. I've reproduced it on `main` with Spark 4.2, and it affects merge-on-read `DELETE` as well as `UPDATE`. `SparkPositionDeltaWrite.BaseDeltaWriter#buildPartitionProjections` projects each spec's `partitionType()` out of `Partitioning.partitionType(table)`. That unified type only keeps partition fields whose source column is still in the schema (`allActiveFieldIds`). Once `p` is dropped, the unified type is `struct<>`, so `StructProjection.create` throws on spec 0's `p` field. The obvious one-liner, switching to `StructProjection.createAllowMissing`, isn't safe. I tried it: the `UPDATE` commits, but the new position deletes/DVs carry `p=null` while the data files are still `p='a'`, and the next read fails in `DeleteFileIndex.validatePartitionMatch` with "Mismatched partition tuples ... metadata is corrupted". The value can't come through `_partition` either, because once the source is dropped the identity result type becomes `unknown` (`NullType` in Spark). What I'd propose: on the driver, for scan tasks whose spec has fields missing from the unified partition type, collect each data file's own partition tuple (`task.file().partition()`). Broadcast it alongside the rewritable deletes, and have the delta writers use that tuple for deletes against those files, using the fanout delete writer in that case because `_partition` can no longer cluster them. For tests, I'd add regression tests to `TestUpdate` and `TestDelete` in `spark/v4.2/spark-extensions` that cover both copy-on-write and merge-on-read, then backport to 3.5/4.0/4.1 in a follow-up. -- 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]
