ayushtkn commented on code in PR #6565:
URL: https://github.com/apache/hive/pull/6565#discussion_r3510737819


##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HiveSchemaUtil.java:
##########
@@ -154,6 +154,23 @@ public static Type convert(TypeInfo typeInfo, String 
defaultValue) {
     return HiveSchemaConverter.convert(typeInfo, false, defaultValue);
   }
 
+  public static Type applyInitialDefaultsToStruct(Type type) {
+    Types.StructType struct = type.asStructType();
+    return Types.StructType.of(
+        
struct.fields().stream().map(HiveSchemaUtil::applyInitialDefaultsToStructField).toList());
+  }
+
+  private static Types.NestedField 
applyInitialDefaultsToStructField(Types.NestedField field) {
+    Types.NestedField.Builder builder = Types.NestedField.from(field);
+    if (field.type().isStructType()) {
+      builder.ofType(applyInitialDefaultsToStruct(field.type()));
+    }
+    if (field.initialDefaultLiteral() == null && field.writeDefaultLiteral() 
!= null) {
+      builder.withInitialDefault(field.writeDefaultLiteral());
+    }

Review Comment:
   Doesn't make sense to me at all and anybody seeing in future will think of 
it is as a bug only. that we landed up setting writeDefault in Initial Default



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