diff --git a/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java b/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java index c6baead8a747..aa7c120aebe8 100644 --- a/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java +++ b/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java @@ -123,6 +123,17 @@ public void testAddSchemaFromJson() { assertEquals(action, actualUpdate, MetadataUpdateParser.fromJson(json)); } + @Test + public void testAddSchemaFromJsonWithoutLastColumnId() { + String action = MetadataUpdateParser.ADD_SCHEMA; + Schema schema = ID_DATA_SCHEMA; + int lastColumnId = schema.highestFieldId(); + String json = + String.format("{\"action\":\"add-schema\",\"schema\":%s}", SchemaParser.toJson(schema)); + MetadataUpdate actualUpdate = new MetadataUpdate.AddSchema(schema, lastColumnId); + assertEquals(action, actualUpdate, MetadataUpdateParser.fromJson(json)); + } + @Test public void testAddSchemaToJson() { Schema schema = ID_DATA_SCHEMA;