Copilot commented on code in PR #801:
URL: https://github.com/apache/iceberg-cpp/pull/801#discussion_r3654021183


##########
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:
   `summary` is defined as an optional column in the snapshots table schema, 
but `Scan()` always appends a (possibly empty) map. In particular, 
`SnapshotFromJson` leaves `Snapshot::summary` empty when the JSON `summary` 
field is absent, so the current implementation will materialize an empty map 
instead of a null, making it impossible for consumers to distinguish “missing 
summary” from “present but empty” (and inconsistent with `operation`, which 
becomes null when `summary` is absent). Consider appending null when 
`snapshot->summary` is empty.



-- 
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]

Reply via email to