Skip to content

Fix inspect.entries() when column_sizes is missing - #4199

Merged
kevinjqliu merged 4 commits into
apache:mainfrom
Rahul-cs50:fix/4186-entries-missing-column-sizes
Nov 19, 2026
Merged

kevinjqliu merged 4 commits into
apache:mainfrom
Rahul-cs50:fix/4186-entries-missing-column-sizes

Conversation

@Rahul-cs50

@Rahul-cs50 Rahul-cs50 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4186

Rationale for this change

column_sizes is optional in a data file, but inspect.entries() builds it with dict(entry.data_file.column_sizes), which raises TypeError: 'NoneType' object is not iterable when the field is absent. DuckDB omits it from the files it writes, and Iceberg Java's deletion vectors carry no column metrics, so entries() fails on those tables.

This applies the or {} that #1902 added to value_counts, null_value_counts, and nan_value_counts. files() and the readable_metrics column already handle the missing field.

Note: entries() reports a missing metric map as an empty map, while files() and Java report null. Aligning all four maps with Java changes existing output, so it is left for a follow-up.

Are these changes tested?

Yes. test_inspect_entries_and_files_with_data_file_without_metrics commits a data file without metrics and reads entries() and files(). Without the fix it fails with the TypeError above.

  • uv run python -m pytest -m unit tests/table/test_inspect.py: 9 passed
  • pre-commit hooks (ruff, ruff format, mypy): passed

Are there any user-facing changes?

inspect.entries() no longer raises on data or delete files without column_sizes.

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

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

Closes apache#4186

@kevinjqliu kevinjqliu 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.

LGTM!

"record_count": entry.data_file.record_count,
"file_size_in_bytes": entry.data_file.file_size_in_bytes,
"column_sizes": dict(entry.data_file.column_sizes),
"column_sizes": dict(entry.data_file.column_sizes or {}),

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.

thanks, this should be optional.

spec reference: https://iceberg.apache.org/spec/#manifest-schema

Screenshot 2026-11-19 at 12 19 42 PM

The snapshot producer now reads DataFile.spec_id, so the test failed
after rebasing onto main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kevinjqliu
kevinjqliu force-pushed the fix/4186-entries-missing-column-sizes branch from 2d453fb to f6eadf1 Compare November 19, 2026 20:23
inspect only reads manifests, so the data file doesn't need to exist.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kevinjqliu kevinjqliu changed the title Fix inspect.entries() for data files without column_sizes Fix inspect.entries() when column_sizes is missing Nov 19, 2026
@kevinjqliu
kevinjqliu enabled auto-merge November 19, 2026 20:26
@kevinjqliu

Copy link
Copy Markdown
Contributor

Thanks @Rahul-cs50 i pushed 2 commits

  • f6eadf1 to fix rebase conflict
  • f712a04 to optimize the test and not write any parquet files

@ebyhr thanks for the review!

@kevinjqliu
kevinjqliu added this pull request to the merge queue Nov 19, 2026
Merged via the queue into apache:main with commit b84df8d Nov 19, 2026
20 checks passed
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

4 participants