-
Notifications
You must be signed in to change notification settings - Fork 183
Added a fix for column rename in IcebergSchemaSync #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,6 +335,33 @@ void testAddMapFieldComment() { | |
verify(mockUpdateSchema).commit(); | ||
} | ||
|
||
@Test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a unit test which writes an actual iceberg table to a tempDir path? There are many examples in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will take a look and will add it @vinishjail97 |
||
public void testUpdateColumnName() { | ||
UpdateSchema mockUpdateSchema = Mockito.mock(UpdateSchema.class); | ||
when(mockTransaction.updateSchema()).thenReturn(mockUpdateSchema); | ||
schemaSync.sync(SCHEMA, updateColumnName(2), mockTransaction); | ||
|
||
verify(mockUpdateSchema).renameColumn(SCHEMA.findColumnName(2), "updateColumnName"); | ||
verify(mockUpdateSchema).commit(); | ||
} | ||
|
||
private Schema updateColumnName(int fieldId) { | ||
List<Types.NestedField> fields = new ArrayList<>(); | ||
for (Types.NestedField existingField : SCHEMA.columns()) { | ||
if (existingField.fieldId() == fieldId) { | ||
fields.add( | ||
Types.NestedField.of( | ||
existingField.fieldId(), | ||
existingField.isOptional(), | ||
"updateColumnName", | ||
existingField.type())); | ||
} else { | ||
fields.add(existingField); | ||
} | ||
} | ||
return new Schema(fields); | ||
} | ||
|
||
private Schema addColumnToDefault(Schema schema, Types.NestedField field, Integer parentId) { | ||
List<Types.NestedField> fields = new ArrayList<>(); | ||
for (Types.NestedField existingField : schema.columns()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think column name should be done after updating the type?
The UT's are failing are probably because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved after updating the type and still it is failing. I will take a look