underdog-tmac opened a new pull request, #3735:
URL: https://github.com/apache/iceberg-rust/pull/3735

   ## What
   
   Adds `UpdateSchemaAction::update_column_type(name, new_type)`, which widens 
a primitive column's type in place while keeping its field id, name, 
nullability, doc and defaults. Only the promotions the [spec 
allows](https://iceberg.apache.org/spec/#schema-evolution) are accepted at 
commit time:
   
   - `int` → `long`
   - `float` → `double`
   - `decimal(P, S)` → `decimal(P', S)` with `P' > P`
   
   The column name may be a dotted path into a struct (`person.age`). 
Validation follows the existing additions and deletions: a missing column, a 
non-primitive column or target type, a non-promotion, a column that is also 
being deleted, or two updates of the same column fail with 
`PreconditionFailed`. The check itself is exposed as `is_type_promotion(from, 
to)`.
   
   ## Why
   
   `Transaction::update_schema()` can add and delete columns but cannot promote 
a type, which the spec permits and which Java's 
`UpdateSchema.updateColumn(name, newType)` offers. A writer that follows a 
source whose column widened (for example CDC from PostgreSQL after `integer` → 
`bigint`) currently has no way to evolve the table through the crate: the 
transaction types are crate-private, so the only options are a hand-written 
metadata commit or a patched crate.
   
   ## Notes
   
   - The name mapping needs no change: a promotion keeps both the field id and 
the name.
   - Existing data files keep the narrower type and are read through the 
promotion, as the spec defines.
   - Tests: `test_is_type_promotion`, 
`test_update_column_type_promotes_in_place` (widens `person.age` and adds a 
column in the same action; field id, requiredness and every other field 
unchanged; `SetCurrentSchema` to the last schema id), 
`test_update_column_type_rejects_everything_but_promotions`.
   - Written with the help of an AI coding assistant (Claude Code); reviewed 
and tested by the author.
   


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