SourabhBadhya commented on code in PR #5254:
URL: https://github.com/apache/hive/pull/5254#discussion_r1686361679


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergAcidUtil.java:
##########
@@ -196,6 +213,32 @@ public static long computePartitionHash(Record rec) {
     return computeHash(part);
   }
 
+  public static PartitionKey parsePartitionKey(Record rec) {
+    String serializedStr = rec.get(SERDE_META_COLS.get(PARTITION_PROJECTION), 
String.class);
+    return SerializationUtil.deserializeFromBase64(serializedStr);
+  }
+
+  public static String getSerializedPartitionKey(Record rec, PartitionSpec 
partitionSpec) {
+    GenericRecord current = GenericRecord.create(partitionSpec.schema());
+    for (int index = 0; index < rec.size(); index++) {
+      current.set(index, rec.get(index));
+    }
+    StructLike structLike = new 
InternalRecordWrapper(partitionSpec.schema().asStruct()).wrap(current);
+    PartitionKey partitionKey = new PartitionKey(partitionSpec, 
partitionSpec.schema());
+    partitionKey.partition(structLike);
+    return SerializationUtil.serializeToBase64(partitionKey);
+  }
+
+  public static String getSerializedPartitionKey(StructLike structLike, 
PartitionSpec partitionSpec) {
+    PartitionKey partitionKey = new PartitionKey(partitionSpec, 
partitionSpec.schema());
+    if (structLike != null) {

Review Comment:
   The `structLike` object we get contains the partition information only and 
not the entire row information. Hence the for-loop iteration is not correct.



##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergAcidUtil.java:
##########
@@ -204,7 +247,7 @@ public static long parseFilePosition(Record rec) {
     return rec.get(FILE_READ_META_COLS.get(MetadataColumns.ROW_POSITION), 
Long.class);
   }
 
-  public static long computeHash(StructProjection struct) {
+  public static long computeHash(StructLike struct) {

Review Comment:
   Partition objects retrieved during Merge task are in StructLike object.



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