openinx commented on a change in pull request #2465:
URL: https://github.com/apache/iceberg/pull/2465#discussion_r617170445
##########
File path: core/src/main/java/org/apache/iceberg/SchemaUpdate.java
##########
@@ -317,6 +333,38 @@ public UpdateSchema unionByNameWith(Schema newSchema) {
return this;
}
+ @Override
+ public UpdateSchema addIdentifierField(String name) {
+ Types.NestedField field = schema.findField(name);
+ if (field == null) {
+ field = adds.get(TABLE_ROOT_ID).stream()
+ .filter(f -> f.name().equals(name))
+ .findAny().orElse(null);
Review comment:
I did not realize that we could add a single column name `response.code`
in this `addColumn` API (Checked the code, sounds like the correct way to add
`response.code` as top-level column is: `addColumn(null, "response.code",
type, doc)` ).
If we wanna to distinguish between the nested columns and the top-level
column whose name contains DOT, then we will need to add extra API for this ,
right ?
```java
// This is used to add columns that does not contains DOT.
UpdateSchema setIdentifierFields(Colleciton<String> names);
// This is used to add nested columns or top-level columns that contains DOT
UpdateSchema setIdentifierFields(Collection<Pair<String, String>>
parentAndNames);
```
##########
File path: api/src/main/java/org/apache/iceberg/Schema.java
##########
@@ -158,6 +186,10 @@ public StructType asStruct() {
return struct.fields();
}
+ public Set<Integer> identifierFieldIds() {
Review comment:
Nit: Better to add a javadoc for this public API.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]