Skip to content

feat(inspect): scan metadata tables through data tasks - #19

Open
manuzhang wants to merge 1 commit into
mainfrom
metadata-data-task
Open

manuzhang wants to merge 1 commit into
mainfrom
metadata-data-task

Conversation

@manuzhang

@manuzhang manuzhang commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

What

  • Add DataTask, a ScanTask whose Rows() returns StructLike rows, and ScanTask::Kind::kDataTask.
  • Add ReadDataTasks() in iceberg/data_task_reader.h. It converts the rows of one or more data tasks to an ArrowArrayStream in batches of bounded size, including nested structs, lists, maps, decimals, and binary and fixed values.
  • Add MetadataTable::NewScan(), which returns a MetadataTableScanBuilder (Select, CaseSensitive, UseSnapshot, UseRef, AsOfTime). The builder creates a MetadataTableScan, a TableScan whose PlanFiles() returns data tasks. Each metadata table implements a private MakeScan().
  • Add ReadMetadataTable() in iceberg/inspect/metadata_table_reader.h. It plans a metadata table scan and reads all of its rows as one ArrowArrayStream, so a read is NewScan()->Select(...).Build() followed by one call.
  • Add an internal StaticDataTask for rows held in memory. It applies the scan's column selection, so tables have no projection code of their own.
  • Move SnapshotsTable to the new interface. Its rows are views of each Snapshot, and it no longer builds Arrow arrays.
  • Implement HistoryTable scans: one row per snapshot log entry with made_current_at, snapshot_id, parent_id, and is_current_ancestor.
  • Remove TimeTravelMetadataTable and SnapshotSelection. A table that supports time travel overrides supports_time_travel().
  • Remove MetadataTable::Scan() and MetadataTable::kBatchSize, so metadata_table.h no longer uses Arrow types.
  • Add example/metadata_table_example.cc, which reads the snapshots table as Arrow batches and the history table as rows.

Why

MetadataTable::Scan() returned an ArrowArrayStream directly, so each metadata table built Arrow batches itself, and callers could not plan work, select columns, or read rows without Arrow (see the review discussion on apache#801). Splitting a scan into planning DataTasks, whose rows do not depend on any in-memory format, and converting those rows separately keeps the Arrow conversion in one place, gives every metadata table column and snapshot selection through one builder, and lets manifest-backed tables such as those in apache#876 plan one task per manifest that callers can read independently.

Behavior change

  • MetadataTable::Scan() and MetadataTable::kBatchSize are removed. Callers build a scan with NewScan() and read it with ReadMetadataTable(), which returns the same rows in batches of at most 1024 rows by default.
  • Metadata table implementations override MakeScan() instead of Scan().
  • TimeTravelMetadataTable, SnapshotSelection, and Scan(const SnapshotSelection&) are removed. Snapshot selection goes through NewScan(). Selecting a snapshot, a ref other than main, or a timestamp on a table that does not support time travel makes Build() fail.
  • HistoryTable scans return history rows instead of NotSupported.
  • Selecting only some fields of a nested struct column returns NotSupported. No current metadata table has a struct column.

Testing

metadata_table_test passes (32 tests). The existing SnapshotsTable tests keep their expectations and now read through a test helper that builds a default scan and calls ReadMetadataTable(). New tests cover:

  • ReadDataTasks(): nested values and nulls, batches that span tasks, an empty task list, invalid arguments, null row streams, required-field nulls, mismatched scalar types (including nested fields), and rows that do not match the schema.
  • StaticDataTask: selecting and reordering top-level columns, partial selection of a nested struct, and unknown fields.
  • Snapshots and history scans: task planning, column selection, rejected time travel, history after a rollback, a log entry whose snapshot is gone, a table without snapshots, and the batch size passed to ReadMetadataTable().

metadata_table_example compiles in C++23 with only the public include directories. Run on src/iceberg/test/resources/TableMetadataV2Valid.json, it prints 2 snapshots and both history entries.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T16:11:32.823555Z dff9ebd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eebab02697

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/iceberg/data_task_reader.cc

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 731da1f56a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/iceberg/data_task_reader.cc Outdated
@manuzhang
manuzhang force-pushed the metadata-data-task branch 3 times, most recently from e5a8a09 to 0db25f4 Compare October 16, 2026 10:06

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0db25f4323

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/iceberg/data_task_reader.cc Outdated
Metadata tables are now read through a scan. MetadataTable::NewScan()
returns a builder that selects columns and, for tables that support time
travel, a snapshot. The built scan plans DataTasks whose rows are
StructLike rather than Arrow arrays. ReadDataTasks() converts the rows of
any data task to an ArrowArrayStream, and ReadMetadataTable() reads a
whole metadata table scan that way. MetadataTable::Scan() and kBatchSize
are removed, so the metadata table interface no longer uses Arrow types.

SnapshotsTable moves to the new interface, and HistoryTable gains a scan
that returns one row per snapshot log entry. TimeTravelMetadataTable and
SnapshotSelection are removed; a table that supports time travel
overrides supports_time_travel() instead.

example/metadata_table_example.cc reads the snapshots table as Arrow
batches and the history table as rows.

Co-authored-by: Codex <codex@openai.com>
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.

1 participant