zhongyujiang commented on code in PR #4535:
URL: https://github.com/apache/iceberg/pull/4535#discussion_r856417012
##########
core/src/test/java/org/apache/iceberg/TestSchemaUpdate.java:
##########
@@ -1388,34 +1395,39 @@ public void testSetIdentifierFieldsFails() {
.setIdentifierFields("locations.key.zip")
.apply());
- AssertHelpers.assertThrows("add a nested field in list should fail",
Review Comment:
I think we can keep this test, and I think changing the validation logic
might be a better option than changing the assert message.
I feel we shouldn't expose the `element` or `key-value` field in
Preconditions error message because these fields are invisible to the users and
may confuse them. I think a validation from top to bottom can give a more
correct error message.
```
Deque<Integer> deque = Lists.newLinkedList();
while (parentId != null) {
deque.push(parentId);
parentId = idToParent.get(parentId);
}
while (!deque.isEmpty()) {
Types.NestedField parent = idToField.get(deque.pop());
Preconditions.checkArgument(parent.type().isStructType(),
"Cannot add field %s as an identifier field: must not be nested in
%s", field.name(), parent);
Preconditions.checkArgument(parent.isRequired(),
"Cannot add field %s as an identifier field: must not be nested in an
optional field %s",
field.name(), parent);
}
```
WDYT?
--
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]