deniskuzZ commented on code in PR #6074:
URL: https://github.com/apache/hive/pull/6074#discussion_r2355663985


##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HiveSchemaConverter.java:
##########
@@ -51,29 +57,56 @@ private HiveSchemaConverter(boolean autoConvert) {
     this.id = 1;
   }
 
-  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,
+      Map<String, String> defaultValues) {
     HiveSchemaConverter converter = new HiveSchemaConverter(autoConvert);
-    return new Schema(converter.convertInternal(names, typeInfos, comments));
+    return new Schema(converter.convertInternal(names, typeInfos, comments, 
defaultValues));
   }
 
   static Type convert(TypeInfo typeInfo, boolean autoConvert) {
     HiveSchemaConverter converter = new HiveSchemaConverter(autoConvert);
-    return converter.convertType(typeInfo);
+    return converter.convertType(typeInfo, null);
   }
 
-  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,
+      Map<String, String> defaultValues) {
     List<Types.NestedField> result = 
Lists.newArrayListWithExpectedSize(names.size());
     int outerId = id + names.size();
     id = outerId;
     for (int i = 0; i < names.size(); ++i) {
-      result.add(Types.NestedField.optional(outerId - names.size() + i, 
names.get(i), convertType(typeInfos.get(i)),
-          comments.isEmpty() || i >= comments.size() ? null : 
comments.get(i)));
-    }
+      Type type = convertType(typeInfos.get(i), 
defaultValues.get(names.get(i)));
+      String columnName = names.get(i);
+      Types.NestedField.Builder fieldBuilder =
+          Types.NestedField.builder()
+              .asOptional()
+              .withId(outerId - names.size() + i)
+              .withName(columnName)
+              .ofType(type)
+              .withDoc(comments.isEmpty() || i >= comments.size() ? null : 
comments.get(i));
+
+      if (defaultValues.containsKey(columnName)) {
+        if (type.isPrimitiveType()) {
+          Object icebergDefaultValue = 
getDefaultValue(stripQuotes(defaultValues.get(columnName)), type);

Review Comment:
   can we move `stripQuotes` inside of getDefaultValue



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