potatochipcoconut commented on issue #1934:
URL: 
https://github.com/apache/iceberg-python/issues/1934#issuecomment-2831447185

   @choucavalier started playing with your lib and seems like generally what I 
was looking for, ran into issues around UUID (opened issues there and duckdb).
   
   Locally I integrated into my own base model, not sure if it would make sense 
to pull into pyiceberg and expose that way or not?
   e.g.
   ```
   class IcebergBaseModel(BaseModel):
       def model_dump_arrow(self):
           """
           Serialize schema for arrow compatibility.
   
           Uses model_dump() and converts UUID to bytes.
           """
           res = {}
   
           for k, v in self.model_dump().items():
               # convert uuid to bytes (pyarrow 19+).
               res[k] = v.bytes if is_valid_uuid(v) else v
   
           return res
   
       @classmethod
       def model_arrow_schema(cls):
           """
           Generate a pyarrow schema from pydantic schema.
   
           Uses code from pydantic-to-pyarrow:
           https://github.com/simw/pydantic-to-pyarrow
   
           Returns:
               The pyarrow schema.
           """
           return get_pyarrow_schema(cls, allow_losing_tz=True)
   
   
   ------
   
   from pyiceberg import IcebergBaseModel
   
   class MySchema(IcebergBaseModel):
       id: uuid.UUID
   ```


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