jeppe-dos commented on PR #1433:
URL: https://github.com/apache/iceberg-python/pull/1433#issuecomment-2557064966

   > Looks like there might be a bug with this change. I tried to follow the 
docs
   > 
   > ```
   > from pyiceberg.catalog.sql import SqlCatalog
   > from pyiceberg.schema import Schema
   > from pyiceberg.types import NestedField, StringType, DoubleType, LongType
   > 
   > warehouse_path = "/tmp/warehouse"
   > catalog = SqlCatalog(
   >     "default",
   >     **{
   >         "uri": f"sqlite:///{warehouse_path}/pyiceberg_catalog.db",
   >         "warehouse": f"file://{warehouse_path}",
   >     },
   > )
   > 
   > schema = Schema(
   >     NestedField(1, "city", StringType(), required=False),
   >     NestedField(2, "lat", DoubleType(), required=False),
   >     NestedField(3, "long", DoubleType(), required=False),
   > )
   > catalog.create_namespace_if_not_exists("default")
   > try:
   >     catalog.drop_table("default.locations")
   > except:
   >     pass
   > 
   > table = catalog.create_table("default.locations", schema)
   > 
   > # with table.update_schema() as update:
   > #     # In a struct
   > #     update.add_column("details.confirmed_by", StringType(), "Name of the 
exchange")
   > 
   > with table.update_schema() as update:
   >     update.add_column(("details", "confirmed_by"), StringType(), "Name of 
the exchange")
   > ```
   > 
   > errors
   > 
   > ```
   > 
   > Traceback (most recent call last):
   >   File "<stdin>", line 2, in <module>
   >   File 
"/Users/kevinliu/repos/iceberg-python/pyiceberg/table/update/schema.py", line 
192, in add_column
   >     parent_field = self._schema.find_field(parent_full_path, 
self._case_sensitive)
   >                    
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   >   File "/Users/kevinliu/repos/iceberg-python/pyiceberg/schema.py", line 
215, in find_field
   >     raise ValueError(f"Could not find field with name {name_or_id}, 
case_sensitive={case_sensitive}")
   > ValueError: Could not find field with name details, case_sensitive=True
   > ```
   
   Yes, the struct has to exist before you can insert anything into it. This 
can be adjusted in the code to automatically create the parent. For now, it is 
detailed in the documentation changes. Should I write more explicitly? 


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