Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ private static Map<Integer, Supplier<UpdateSchema>> addUpdates(
parentPath, latestColumn.name(), latestColumn.type(), latestColumn.doc()));
}
} else if (latestColumn == null) {
// drop the existing column, use fieldId 0 to perform deletes first
// drop the existing column; a negative key performs deletes first, and the column's own
// id keeps several deletes from replacing one another
updates.put(
0,
-currentColumn.fieldId(),
() -> updateSchema.deleteColumn(constructFullyQualifiedName(columnName, parentPath)));
} else {
updates.putAll(updateColumn(latestColumn, currentColumn, updateSchema, parentPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ public void testDropColumn() {
verify(mockUpdateSchema).commit();
}

@Test
void dropsEveryColumnRemovedInOneSync() {
UpdateSchema mockUpdateSchema = Mockito.mock(UpdateSchema.class);
when(mockTransaction.updateSchema()).thenReturn(mockUpdateSchema);

Schema withoutFirstTwoColumns =
new Schema(SCHEMA.columns().subList(2, SCHEMA.columns().size()));
schemaSync.sync(SCHEMA, withoutFirstTwoColumns, mockTransaction);

verify(mockUpdateSchema).deleteColumn("timestamp_field");
verify(mockUpdateSchema).deleteColumn("date_field");
verify(mockUpdateSchema).commit();
}

@Test
public void testAddNestedColumn() {
String columnName = "addedColumn";
Expand Down