Rahul-cs50 opened a new pull request, #4199:
URL: https://github.com/apache/iceberg-python/pull/4199

   Closes #4186
   
   # Rationale for this change
   
   `column_sizes` is an optional field of a data file, but `inspect.entries()` 
builds it with `dict(entry.data_file.column_sizes)`, so an entry without it 
raises `TypeError: 'NoneType' object is not iterable`. DuckDB writes data files 
without `column_sizes`, so `entries()` fails on tables it wrote. #1902 already 
added `or {}` to the three count maps next to it (`value_counts`, 
`null_value_counts`, `nan_value_counts`); this applies the same to 
`column_sizes`. The `readable_metrics` part of `entries()` and `files()` 
already handle a missing `column_sizes`.
   
   Note: with this, `entries()` reports a missing map as an empty map, like the 
three count maps, while `files()` reports `null`. I kept `entries()` consistent 
with its neighbours; happy to switch all four to `null` instead if you'd prefer.
   
   ## Are these changes tested?
   
   Yes. `test_inspect_entries_and_files_with_data_file_without_metrics` in 
`tests/table/test_inspect.py` appends a data file that has no metrics (as in 
the issue's repro) and reads `entries()` and `files()`. It fails on `main` with 
the `TypeError` above and passes with this change. `tests/table` and 
`tests/catalog/test_base.py` unit tests: 545 passed. `ruff check` and `ruff 
format --check` are clean.
   
   ## Are there any user-facing changes?
   
   `inspect.entries()` no longer raises on data files without `column_sizes`.
   


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