rdblue commented on a change in pull request #3912:
URL: https://github.com/apache/iceberg/pull/3912#discussion_r786925851



##########
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;
+      String name = names.get(i);
+      String doc = (comments.isEmpty() || i >= comments.size()) ? null : 
comments.get(i);
+      if (identifierFieldSet.contains(name)) {

Review comment:
       I don't think this logic would work with nested identifier field names. 
For example, an integer field, `response.status` could be in the set of names, 
but this would not catch it.




-- 
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]

Reply via email to