Skip to content

Fix inspect.entries() for data files without column_sizes - #4199

Open
Rahul-cs50 wants to merge 2 commits into
apache:mainfrom
Rahul-cs50:fix/4186-entries-missing-column-sizes
Open

Rahul-cs50 wants to merge 2 commits into
apache:mainfrom
Rahul-cs50:fix/4186-entries-missing-column-sizes

Conversation

@Rahul-cs50

Copy link
Copy Markdown

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.

column_sizes is optional in a data file, but entries() built it with
dict(entry.data_file.column_sizes), which raises TypeError when it is
missing. DuckDB writes data files without it. Use the `or {}` that
apache#1902 added to the three count maps next to it.

Closes apache#4186
Copilot AI balanced review requested due to automatic review settings October 30, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Comment thread tests/table/test_inspect.py Outdated
Comment on lines +82 to +83
# column_sizes and the other metric maps are optional in a data file; DuckDB, for one,
# writes data files without column_sizes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The spec already makes these maps optional, so the DuckDB aside isn't needed. Could shorten to one line: "# column_sizes and the other metric maps are optional in a data file"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2d453fb, thanks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inspect.entries() raises TypeError when a data file has no column_sizes

3 participants

⌂ Proxy