Skip to content

Commit

Permalink
Spec: Add missing last-column-id (#7445)
Browse files Browse the repository at this point in the history
* Spec: Add missing last-column-id to open-api spec

* Add description
  • Loading branch information
Fokko authored Jun 5, 2023
1 parent 2fe8e13 commit 26af4c7
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 @@ -1502,6 +1502,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. When omitted, it will be computed on the server side.

SetCurrentSchemaUpdate:
allOf:
Expand Down

0 comments on commit 26af4c7

Please sign in to comment.