difin commented on code in PR #5248: URL: https://github.com/apache/hive/pull/5248#discussion_r1640352883
########## iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergTableUtil.java: ########## @@ -344,4 +364,95 @@ public static PartitionData toPartitionData(StructLike key, Types.StructType key } return data; } + + public static PartitionData toPartitionData(StructLike sourceKey, Types.StructType sourceKeyType, + Types.StructType targetKeyType) { + PartitionData data = new PartitionData(targetKeyType); + for (int i = 0; i < targetKeyType.fields().size(); i++) { + + int fi = i; + Object sourceKeyElem = sourceKeyType.fields().stream() + .filter(f -> f.name().equals(targetKeyType.fields().get(fi).name())).findFirst().get(); + + Object val = sourceKey.get(sourceKeyType.fields().indexOf(sourceKeyElem), + targetKeyType.fields().get(i).type().typeId().javaClass()); + if (val != null) { + data.set(i, val); + } + } + return data; + } + + public static Pair<List<DataFile>, List<DeleteFile>> getDataAndDeleteFiles(Table table, int specId, Review Comment: Done, split into 2 methods. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org