Yibo-Dong opened a new issue, #19269:
URL: https://github.com/apache/iceberg/issues/19269

   ### Apache Iceberg version
   
   main (development)
   
   ### Query engine
   
   Spark
   
   ### Please describe the bug 🐞
   
   `REPLACE TABLE` that changes the type of a column but keeps its name reuses 
the column's field ID. Branches (and `main` after a rollback) are read with the 
new schema, so the old values are decoded as the new type: below, INT `100` is 
read as DATE `1970-04-11`. Reproduced on `main` (3bfa3e4, 2026-12-01) and 
1.12.0, Spark 3.5.5.
   
   ### Reproduction
   
   ```sql
   CREATE TABLE local.db.t (id INT, v INT) USING iceberg;
   INSERT INTO local.db.t VALUES (1, 100);
   ALTER TABLE local.db.t CREATE BRANCH b;
   ALTER TABLE local.db.t CREATE TAG g;
   -- v keeps its name but changes type INT -> DATE
   REPLACE TABLE local.db.t (id INT, v DATE) USING iceberg;
   
   -- control: the tag is read with its snapshot schema
   SELECT 'tag g', id, v FROM local.db.t VERSION AS OF 'g';
   SELECT 'branch b', id, v FROM local.db.t VERSION AS OF 'b';
   ```
   
   ### Expected
   
   | Query | Result |
   |---|---|
   | `tag g` (control) | `1 100` |
   | `branch b` | `1 100` (or `v` read as NULL as a new column) |
   
   ### Actual
   
   | Query | Result |
   |---|---|
   | `tag g` (control) | `1 100` |
   | `branch b` | `1 1970-04-11` |
   
   
   ### Additional Info
   A field ID may only change type through the [valid type 
promotions](https://iceberg.apache.org/spec/#schema-evolution), and `int -> 
date` is not one: `ALTER TABLE local.db.t ALTER COLUMN v TYPE DATE` is rejected 
(`NOT_SUPPORTED_CHANGE_COLUMN`), and the Iceberg API 
`UpdateSchema.updateColumn` rejects it with `Cannot change column type: v: int 
-> date`. `REPLACE TABLE` bypasses that check.
   
   ### 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
   - [x] 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]

Reply via email to