WZhuo commented on code in PR #801:
URL: https://github.com/apache/iceberg-cpp/pull/801#discussion_r3689141956
##########
src/iceberg/inspect/snapshots_table.cc:
##########
@@ -65,4 +68,50 @@ Result<std::unique_ptr<SnapshotsTable>> SnapshotsTable::Make(
return std::unique_ptr<SnapshotsTable>(new SnapshotsTable(std::move(table)));
}
+Result<ArrowArray> SnapshotsTable::Scan(
+ const std::optional<SnapshotSelection>& /*snapshot_selection*/) {
+ ICEBERG_ASSIGN_OR_RAISE(auto builder, ArrowRowBuilder::Make(*schema()));
+
+ for (const auto& snapshot : source_table()->snapshots()) {
+ if (snapshot == nullptr) [[unlikely]] {
+ continue;
+ }
+
+ // column 0: committed_at (timestamptz -> int64 micros)
+ ICEBERG_RETURN_UNEXPECTED(AppendInt(
+ builder.column(0),
std::chrono::duration_cast<std::chrono::microseconds>(
+ snapshot->timestamp_ms.time_since_epoch())
+ .count()));
+
+ // column 1: snapshot_id (long)
+ ICEBERG_RETURN_UNEXPECTED(AppendInt(builder.column(1),
snapshot->snapshot_id));
+
+ // column 2: parent_id (long, optional)
+ if (snapshot->parent_snapshot_id.has_value()) {
+ ICEBERG_RETURN_UNEXPECTED(
+ AppendInt(builder.column(2), *snapshot->parent_snapshot_id));
+ } else {
+ ICEBERG_RETURN_UNEXPECTED(AppendNull(builder.column(2)));
+ }
+
+ // column 3: operation (string, optional)
+ auto op = snapshot->Operation();
+ if (op.has_value()) {
+ ICEBERG_RETURN_UNEXPECTED(AppendString(builder.column(3), *op));
+ } else {
+ ICEBERG_RETURN_UNEXPECTED(AppendNull(builder.column(3)));
+ }
+
+ // column 4: manifest_list (string, optional)
+ ICEBERG_RETURN_UNEXPECTED(AppendString(builder.column(4),
snapshot->manifest_list));
+
+ // column 5: summary (map<string,string>)
+ ICEBERG_RETURN_UNEXPECTED(AppendStringMap(builder.column(5),
snapshot->summary));
Review Comment:
Done. `SnapshotSummaryFields::kOperation` is removed before materializing
`summary`. The current implementation emits null when the remaining map is
empty, and tests cover both operation omission and empty-summary handling.
--
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]