Fokko commented on issue #1726:
URL: 
https://github.com/apache/iceberg-python/issues/1726#issuecomment-2692854196

   Hey @mariotaddeucci Can you share more about the context around this 
functionality? Also, based on what I see in the implementation in #1727 I'm 
reluctant adding this.
   
   In the PR, if you have a table with data, and you only replace the schema 
using the newly added API, it will return rows with all null values (since they 
are projected into the schema). If you want an API similar to [Union by 
Name](https://py.iceberg.apache.org/api/#union-by-name), where you update the 
fields based on the changes, then this makes sense to me. For example:
   
   ```python
   from pyiceberg.catalog import load_catalog
   from pyiceberg.schema import Schema
   from pyiceberg.types import NestedField, StringType, DoubleType
   catalog = load_catalog()
   initial_schema = Schema(
       NestedField(1, "city_name", StringType(), required=False),
       NestedField(2, "latitude", FloatType(), required=False),
       NestedField(3, "longitude", FloatType(), required=False),
   )
   
   table = catalog.create_table("default.locations", initial_schema)
   new_schema = Schema(
       NestedField(1, "city", StringType(), required=False),
       NestedField(2, "lat", DoubleType(), required=False),
       NestedField(3, "long", DoubleType(), required=False),
       NestedField(4, "population", LongType(), required=False),
   )
   with table.update_schema() as update:
       update.overwrite(new_schema)
   
   # The big difference here is that if the field ID already exists, then we 
update the name/type/doc etc
   assert new_schema == tbl.schema()
   ```


-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to