somasays opened a new pull request, #2797:
URL: https://github.com/apache/iceberg-python/pull/2797

   ## Summary
   - Fixes #2684: Writing to a table with an optional map field fails when the 
data is missing that field
   - Modified `_SchemaCompatibilityVisitor.field()` to skip child validation 
when optional parent is missing
   - Added 5 unit tests for schema compatibility with optional nested fields
   
   ## Root Cause
   When writing data to a table with an optional map field, the schema 
compatibility check incorrectly failed if the data was missing that field. This 
happened because the validator descended into the map's internal key field 
(which is always `required=True` per Iceberg spec) even when the parent map 
field was optional and missing.
   
   ## The Fix
   Modified `_SchemaCompatibilityVisitor.field()` in `pyiceberg/schema.py` to 
check if the field exists in the provided schema before descending into 
children. If an optional parent field is missing, we skip child validation 
entirely.
   
   ## Test plan
   - [x] All 328 schema tests pass
   - [x] Lint passes (`make lint`)
   - [x] New tests cover:
     - Optional map field missing (should pass) - main fix
     - Required map field missing (should fail)
     - Optional list field missing (should pass)
     - Optional struct field missing (should pass)
     - Optional map field present (should pass)


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