ayushtkn commented on code in PR #6565:
URL: https://github.com/apache/hive/pull/6565#discussion_r3510729130
##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -744,12 +744,14 @@ private void
handleAddColumns(org.apache.hadoop.hive.metastore.api.Table hmsTabl
boolean isORc = isOrcFileFormat(hmsTable);
for (FieldSchema addedCol : addedCols) {
String defaultValue = defaultValues.get(addedCol.getName());
- Type type =
HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(addedCol.getType()),
defaultValue);
- Literal<Object> defaultVal = Optional.ofNullable(defaultValue).filter(v
-> !type.isStructType())
- .map(v -> Expressions.lit(HiveSchemaUtil.getDefaultValue(v,
type))).orElse(null);
-
+ Type baseType =
HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(addedCol.getType()),
defaultValue);
+ final Type resolvedType = (!isORc && baseType.isStructType()) ?
+ HiveSchemaUtil.applyInitialDefaultsToStruct(baseType) :
+ baseType;
+ Literal<Object> defaultVal = Optional.ofNullable(defaultValue).filter(v
-> !resolvedType.isStructType())
+ .map(v -> Expressions.lit(HiveSchemaUtil.getDefaultValue(v,
resolvedType))).orElse(null);
// ORC doesn't have support for initialDefault from iceberg layer, we
only need to set default for writeDefault.
- updateSchema.addColumn(addedCol.getName(), type, addedCol.getComment(),
isORc ? null : defaultVal);
+ updateSchema.addColumn(addedCol.getName(), resolvedType,
addedCol.getComment(), isORc ? null : defaultVal);
Review Comment:
this approach ain't nice either, it looks overcomplicated to me
--
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]