Yibo-Dong opened a new issue, #19286:
URL: https://github.com/apache/iceberg/issues/19286
### Apache Iceberg version
main (development)
### Query engine
Spark
### Please describe the bug 🐞
After a partition field is renamed and a new partition field takes its old
name, `rewrite_position_delete_files` treats the deletes of the old spec as
deletes of removed files and drops them, so deleted rows come back. Reproduced
on `main` (3bfa3e4, 2026-12-01) and 1.12.0, Spark 3.5.5.
### Reproduction
```sql
CREATE TABLE local.db.t (id INT, p INT) USING iceberg PARTITIONED BY (p)
TBLPROPERTIES ('write.delete.mode'='merge-on-read');
INSERT INTO local.db.t VALUES (1, 1), (2, 1), (3, 1);
DELETE FROM local.db.t WHERE id IN (1, 2);
-- rename partition field p to p_old, then add a new partition field named p
ALTER TABLE local.db.t REPLACE PARTITION FIELD p WITH p AS p_old;
ALTER TABLE local.db.t ADD PARTITION FIELD truncate(10, p) AS p;
SELECT 'before', collect_list(id) FROM local.db.t;
CALL local.system.rewrite_position_delete_files(table => 'db.t', options =>
map('rewrite-all', 'true'));
SELECT 'after', collect_list(id) FROM local.db.t;
-- control: the new partition field gets another name
CREATE TABLE local.db.c (id INT, p INT) USING iceberg PARTITIONED BY (p)
TBLPROPERTIES ('write.delete.mode'='merge-on-read');
INSERT INTO local.db.c VALUES (1, 1), (2, 1), (3, 1);
DELETE FROM local.db.c WHERE id IN (1, 2);
ALTER TABLE local.db.c ADD PARTITION FIELD truncate(10, p) AS p10;
CALL local.system.rewrite_position_delete_files(table => 'db.c', options =>
map('rewrite-all', 'true'));
SELECT 'control', collect_list(id) FROM local.db.c;
```
### Expected
| Query | Result |
|---|---|
| `before` | `[3]` |
| `after` | `[3]` |
| `control` | `[3]` |
### Actual
| Query | Result |
|---|---|
| `before` | `[3]` |
| `after` | `[1,2,3]` (rows 1 and 2 are back) |
| `control` | `[3]` |
### Willingness to contribute
- [ ] I can contribute a fix for this bug independently
- [ ] I would be willing to contribute a fix for this bug with guidance from
the Iceberg community
- [ ] I cannot contribute a fix for this bug at this time
--
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]