rdblue commented on a change in pull request #3912:
URL: https://github.com/apache/iceberg/pull/3912#discussion_r786924755
##########
File path:
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveSchemaConverter.java
##########
@@ -50,21 +52,32 @@ private HiveSchemaConverter(boolean autoConvert) {
this.id = 0;
}
- static Schema convert(List<String> names, List<TypeInfo> typeInfos,
List<String> comments, boolean autoConvert) {
+ static Schema convert(List<String> names, List<TypeInfo> typeInfos,
List<String> comments, boolean autoConvert,
+ Set<String> identifierFieldSet) {
HiveSchemaConverter converter = new HiveSchemaConverter(autoConvert);
- return new Schema(converter.convertInternal(names, typeInfos, comments));
+ List<Types.NestedField> fields = converter.convertInternal(names,
typeInfos, comments, identifierFieldSet);
+ Set<Integer> identifierIdSet =
HiveSchemaUtil.identifierFieldIdSetOrThrow(fields, identifierFieldSet);
+ return new Schema(fields, identifierIdSet);
}
static Type convert(TypeInfo typeInfo, boolean autoConvert) {
HiveSchemaConverter converter = new HiveSchemaConverter(autoConvert);
return converter.convertType(typeInfo);
}
- List<Types.NestedField> convertInternal(List<String> names, List<TypeInfo>
typeInfos, List<String> comments) {
+ List<Types.NestedField> convertInternal(List<String> names, List<TypeInfo>
typeInfos, List<String> comments,
+ Set<String> identifierFieldSet) {
List<Types.NestedField> result =
Lists.newArrayListWithExpectedSize(names.size());
for (int i = 0; i < names.size(); ++i) {
- result.add(Types.NestedField.optional(id++, names.get(i),
convertType(typeInfos.get(i)),
- (comments.isEmpty() || i >= comments.size()) ? null :
comments.get(i)));
+ int fieldId = id;
+ id = id + 1;
Review comment:
I think it is more direct to use id, but increment it at the end of the
for block.
--
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]