Anurag-S1ngh opened a new pull request, #4551:
URL: https://github.com/apache/iceberg-python/pull/4551

   Closes #3105
   
   # Rationale for this change
   
   `get_rows_to_update` cast the whole source table to the schema of the 
scanned target rows. A scan of a data file written before a column was added 
omits that column, so after `update_schema().union_by_name()` the cast failed 
with:
   
   ```
   ValueError: Target schema's field names are not matching the table's field 
names
   ```
   
   Align the target rows to the source schema by column name and add any 
missing source columns as nulls before the join and comparison. The join now 
selects only the join columns instead of casting the entire table.
   
   This also handles source columns in a different order, which previously 
failed for the same reason.
   
   ## Are these changes tested?
   
   - `pytest tests/table/test_upsert.py` (30 passed)
   - Added a regression test that appends data, adds a column, then upserts a 
row containing the new column. It fails with the reported error before this 
change.
   - Added unit tests for renamed column order and a target missing a source 
column.
   - `ruff check` and `ruff format --check` on the changed files
   
   ## Are there any user-facing changes?
   
   No API change. Upsert now succeeds after a schema evolution that adds a 
column.
   


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