manuzhang commented on code in PR #1169:
URL: https://github.com/apache/iceberg-cpp/pull/1169#discussion_r4749221967


##########
src/iceberg/test/metadata_serde_test.cc:
##########
@@ -499,6 +499,109 @@ TEST(MetadataSerdeTest, V3DefaultValuesRoundTrip) {
   EXPECT_EQ(*reparsed, *metadata);
 }
 
+TEST(MetadataSerdeTest, TableSequenceAndRowIdBoundsCoverRetainedSnapshots) {
+  for (const auto* resource :
+       {"TableMetadataV2ValidMinimal.json", 
"TableMetadataV3ValidMinimal.json"}) {
+    SCOPED_TRACE(resource);
+    ICEBERG_UNWRAP_OR_FAIL(auto empty, 
ReadTableMetadataFromResource(resource));
+    ICEBERG_UNWRAP_OR_FAIL(auto json, ToJson(*empty));
+    json["snapshots"] = nlohmann::json::parse(R"([{
+      "snapshot-id": 1, "sequence-number": 1, "timestamp-ms": 1000,
+      "manifest-list": "metadata/manifest-list.avro", "summary": {"operation": 
"append"},
+      "schema-id": 0, "first-row-id": 1, "added-rows": 10
+    }])");
+    json["last-sequence-number"] = 1;
+    json["next-row-id"] = 11;
+    ICEBERG_UNWRAP_OR_FAIL(auto valid, TableMetadataFromJson(json));
+    for (const auto* field : {"last-sequence-number", "next-row-id"}) {
+      const bool is_next_row_id = std::string_view(field) == "next-row-id";
+      if (is_next_row_id && empty->format_version < 3) {
+        continue;
+      }
+      SCOPED_TRACE(field);
+      auto invalid = json;
+      invalid[field] = 0;

Review Comment:
   Fixed in new tests.



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