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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergAcidUtil.java:
##########
@@ -196,6 +206,30 @@ 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());
+    for (int idx = 0; idx < structLike.size(); idx++) {

Review Comment:
   `partitionKey.partition(structLike)` expects the entire row. Whereas we have 
information of the exact partition itself hence had to create 2 different 
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: [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