dramaticlly commented on code in PR #18935:
URL: https://github.com/apache/iceberg/pull/18935#discussion_r4594232736
##########
api/src/main/java/org/apache/iceberg/Schema.java:
##########
@@ -603,20 +626,33 @@ private List<NestedField> reassignIds(List<NestedField>
columns, TypeUtil.GetID
if (getID == null) {
return columns;
}
- Type res =
- TypeUtil.assignIds(
- StructType.of(columns),
- oldId -> {
- int newId = getID.get(oldId);
- if (newId != oldId) {
- idsToReassigned.put(oldId, newId);
- idsToOriginal.put(newId, oldId);
- }
- return newId;
- });
+
+ TypeUtil.GetID tracked =
Review Comment:
nit: find a bit confusing on the purpose of tracked. I think we are
basically recording the reassignment of the id by bookkeeping both in the 2 way
map?
##########
core/src/test/java/org/apache/iceberg/TestSchemaUpdate.java:
##########
@@ -2590,4 +2600,193 @@ public void
testCaseInsensitiveMoveAfterNewlyAddedField() {
assertThat(actual.asStruct()).isEqualTo(expected.asStruct());
}
+
+ @Test
+ void cannotAddColumnToFileColumn() {
+ assertThatThrownBy(() -> fileUpdate().addColumn("photo", "extra",
Types.StringType.get()))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Cannot add to non-struct column: photo: file");
+ }
+
+ @Test
+ void cannotDeleteFileNestedField() {
+ assertThatThrownBy(() -> fileUpdate().deleteColumn("photo.checksum"))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Cannot change a nested field of a file column:
photo.checksum");
+ }
+
+ @Test
+ void cannotRenameFileNestedField() {
+ assertThatThrownBy(() -> fileUpdate().renameColumn("photo.uri",
"location"))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Cannot change a nested field of a file column:
photo.uri");
+ }
+
+ @Test
+ void cannotPromoteFileNestedField() {
+ assertThatThrownBy(() -> fileUpdate().updateColumn("photo.size",
Types.LongType.get()))
Review Comment:
photo.size is already a long type before promotion, maybe change to
`StringType` instead to illustrate the point?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]