Repository navigation
Conversation
Co-authored-by: Codex <codex@openai.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open findings
This introduces C++20-only features in implementation code: abbreviated function templates (`const… · NewAppendOptionalalways appends viaAppendInt(... int64_t ...), but column 4 in this table schema… · New This introduces C++20-only features in implementation code: abbreviated function templates (`const… · New The new stream implementation adds batching logic viaMetadataTable::kBatchSize, but the added… · New
What changed in this PR
This PR adds an inspect metadata table (RefsTable) that exposes Iceberg branch/tag snapshot references as an Arrow stream, along with a shared internal helper for emitting bounded Arrow record batches.
Changes:
- Introduces
RefsTable(schema + scan implementation) and wires it into the metadata table kind enum / build system. - Adds a shared internal Arrow row-stream helper to generate bounded Arrow batches from row iterators.
- Adds
RefsTableunit tests (format v2/v3) and integrates them into the test target.
| File | Description |
|---|---|
| src/iceberg/type_fwd.h | Adds forward declaration for RefsTable. |
| src/iceberg/inspect/metadata_table.h | Adds kRefs metadata table kind. |
| src/iceberg/inspect/refs_table.h | Declares the new RefsTable metadata table API. |
| src/iceberg/inspect/refs_table.cc | Implements RefsTable schema + scanning over snapshot refs; sorts results. |
| src/iceberg/inspect/metadata_table_stream_internal.h | Adds internal Arrow stream implementation for iterating rows in bounded batches. |
| src/iceberg/test/inspect/refs_table_test.cc | Adds tests validating schema, sorting, and retention-field projection. |
| src/iceberg/test/CMakeLists.txt | Registers the new refs table tests in the test target. |
| src/iceberg/cpp20_compatibility_internal.h | Includes the new header for compatibility aggregation. |
| src/iceberg/CMakeLists.txt | Adds inspect/refs_table.cc to library sources. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Result<std::optional<ArrowArray>> Next() { | ||
| ICEBERG_PRECHECK(arrow_schema_.release != nullptr, | ||
| "Cannot read from a closed metadata table stream"); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto builder, ArrowRowBuilder::Make(&arrow_schema_)); | ||
| while (builder.num_rows() < MetadataTable::kBatchSize) { | ||
| ICEBERG_ASSIGN_OR_RAISE(auto row, rows_->Next()); | ||
| if (!row.has_value()) { | ||
| break; | ||
| } | ||
| ICEBERG_RETURN_UNEXPECTED(append_row_(builder, *row)); | ||
| } | ||
| if (builder.num_rows() == 0) { | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| ICEBERG_ASSIGN_OR_RAISE(auto array, std::move(builder).Finish()); | ||
| return array; | ||
| } |
Make row errors and exhaustion terminal, validate stream inputs, and store callbacks without type erasure. Reuse the helper for SnapshotsTable and cover batching, lazy reads, failures, cleanup, null metadata, and format version 1. Co-authored-by: Codex <codex@openai.com>
Move the common metadata test fixture into inspect and update history and snapshots includes to match PR apache#1007. Co-authored-by: Codex <codex@openai.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open findings
3 resolved since last review
🧠 Review effort: Lite
| inspect/history_table_test.cc | ||
| inspect/metadata_table_stream_test.cc | ||
| inspect/metadata_table_test.cc | ||
| inspect/refs_table_test.cc | ||
| inspect/snapshots_table_test.cc) |
| Status AppendOptional(ArrowArray* array, const auto& value) { | ||
| if (!value.has_value()) { | ||
| return AppendNull(array); | ||
| } | ||
| return AppendInt(array, static_cast<int64_t>(*value)); | ||
| } | ||
|
|
||
| Status AppendRef(ArrowRowBuilder& builder, const RefRow& ref) { | ||
| ICEBERG_RETURN_UNEXPECTED(AppendString(builder.column(0), ref.name)); | ||
| ICEBERG_RETURN_UNEXPECTED(AppendString(builder.column(1), ref.type)); | ||
| ICEBERG_RETURN_UNEXPECTED(AppendInt(builder.column(2), ref.snapshot_id)); | ||
| ICEBERG_RETURN_UNEXPECTED(AppendOptional(builder.column(3), ref.max_ref_age_ms)); | ||
| ICEBERG_RETURN_UNEXPECTED(AppendOptional(builder.column(4), ref.min_snapshots_to_keep)); | ||
| ICEBERG_RETURN_UNEXPECTED(AppendOptional(builder.column(5), ref.max_snapshot_age_ms)); | ||
| return builder.FinishRow(); | ||
| } |


Add
RefsTableto expose branch and tag snapshot references through an Arrow stream. Its six-column schema includes reference names, uppercaseBRANCH/TAGtypes, snapshot IDs, and optional retention settings; rows are sorted by reference name. Null tables returnkInvalidArgument, while null reference metadata returnskInvalid.The shared metadata row-stream helper validates sources and nullable callbacks, preserves errors and exhaustion through
Stream<ArrowArray>, avoids allocating builders after exhaustion, and stores concrete callbacks.SnapshotsTablenow uses the same helper while retaining captured metadata and skipping null snapshots. Existing metadata test sources and their fixture live alongside the new tests undertest/inspect.Extracted from #876, whose files, partitions, and manifests tables depend on this PR. Regression tests cover vector and lazy sources, multiple batches, append/source failures through the Arrow C callbacks, invalid inputs, close/release behavior, and RefsTable format versions 1, 2, and 3.
Validation: pre-commit and
git diff --checkpassed. Standalone metadata tests: 31 passed. Combined with #876: 87 passed. Hosted CI is separate from these local checks.