The GitHub Actions job "uv in /. - Update #1177961729" on 
iceberg-python.git/main has failed.
Run started by GitHub user dependabot[bot] (triggered by dependabot[bot]).

Head commit for run:
65ba59519170fa795bb7755d73910861c72b17c7 / Somasundaram Sekar 
<[email protected]>
fix: Allow writing data with missing optional map fields (#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)

Co-authored-by: Somasundaram Sekar <[email protected]>

Report URL: https://github.com/apache/iceberg-python/actions/runs/20044964804

With regards,
GitHub Actions via GitBox

Reply via email to