Skip to content
Open
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 @@ -609,14 +609,17 @@ protected void updateLastColumn(
applyRenameColumnsToOptions(newOptions, changes),
newComment);

return new TableSchema(
oldTableSchema.id() + 1,
newSchema.fields(),
highestFieldId.get(),
newSchema.partitionKeys(),
newSchema.primaryKeys(),
newSchema.options(),
newSchema.comment());
TableSchema newTableSchema =
new TableSchema(
oldTableSchema.id() + 1,
newSchema.fields(),
highestFieldId.get(),
newSchema.partitionKeys(),
newSchema.primaryKeys(),
newSchema.options(),
newSchema.comment());
SchemaValidation.validateTableSchema(newTableSchema);
return newTableSchema;
}

// gets the rootType at the defined depth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,47 @@ public void testUpdateOptions() throws Exception {
assertThat(latest.get().options()).containsEntry("new_k", "new_v");
}

@Test
public void testResetSequenceGroupForAggregateFunction() throws Exception {
Map<String, String> options = new HashMap<>();
options.put(CoreOptions.MERGE_ENGINE.key(), "partial-update");
options.put(CoreOptions.BUCKET.key(), "1");
options.put("fields.f2.aggregate-function", "sum");
options.put("fields.f1.sequence-group", "f2");
Schema schema = new Schema(rowType.getFields(), partitionKeys, primaryKeys, options, "");

retryArtificialException(() -> manager.createTable(schema));

assertThatThrownBy(
() ->
retryArtificialException(
() ->
manager.commitChanges(
SchemaChange.removeOption(
"fields.f1.sequence-group"))))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
"Must use sequence group for aggregation functions but not found for field f2.");
}

@Test
public void testResetSequenceGroupForLastNonNullAggregateFunction() throws Exception {
Map<String, String> options = new HashMap<>();
options.put(CoreOptions.MERGE_ENGINE.key(), "partial-update");
options.put(CoreOptions.BUCKET.key(), "1");
options.put("fields.f2.aggregate-function", "last_non_null_value");
options.put("fields.f1.sequence-group", "f2");
Schema schema = new Schema(rowType.getFields(), partitionKeys, primaryKeys, options, "");

retryArtificialException(() -> manager.createTable(schema));
retryArtificialException(
() -> manager.commitChanges(SchemaChange.removeOption("fields.f1.sequence-group")));

Optional<TableSchema> latest = retryArtificialException(() -> manager.latest());
assertThat(latest.isPresent()).isTrue();
assertThat(latest.get().options()).doesNotContainKey("fields.f1.sequence-group");
}

@Test
public void testConcurrentCommit() throws Exception {
retryArtificialException(
Expand Down
Loading