Skip to content

Commit

Permalink
Spec: Add missing last-column-id to open-api spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko committed May 1, 2023
1 parent 4ce5318 commit 443b797
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ private static MetadataUpdate readUpgradeFormatVersion(JsonNode node) {
private static MetadataUpdate readAddSchema(JsonNode node) {
JsonNode schemaNode = JsonUtil.get(SCHEMA, node);
Schema schema = SchemaParser.fromJson(schemaNode);
int lastColumnId = JsonUtil.getInt(LAST_COLUMN_ID, node);
int lastColumnId;
if (node.has(LAST_COLUMN_ID)) {
lastColumnId = JsonUtil.getInt(LAST_COLUMN_ID, node);
} else {
lastColumnId = schema.highestFieldId();
}
return new MetadataUpdate.AddSchema(schema, lastColumnId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions open-api/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,9 @@ components:
properties:
schema:
$ref: '#/components/schemas/Schema'
last-column-id:
type: integer
description: The highest assigned column ID for the table. This is used to ensure columns are always assigned an unused ID when evolving schemas.

SetCurrentSchemaUpdate:
allOf:
Expand Down

0 comments on commit 443b797

Please sign in to comment.