in pyiceberg/table/update/schema.py [0:0]
def field(self, field: NestedField, field_result: Optional[IcebergType]) -> Optional[IcebergType]:
# the API validates deletes, updates, and additions don't conflict handle deletes
if field.field_id in self._deletes:
return None
# handle updates
if (update := self._updates.get(field.field_id)) and field.field_type != update.field_type:
return update.field_type
if isinstance(field_result, StructType):
# handle add & moves
added = self._adds.get(field.field_id)
moves = self._moves.get(field.field_id)
if added is not None or moves is not None:
if not isinstance(field.field_type, StructType):
raise ValueError(f"Cannot add fields to non-struct: {field}")
if new_fields := _add_and_move_fields(field_result.fields, added or [], moves or []):
return StructType(*new_fields)
return field_result