deniskuzZ commented on code in PR #5136:
URL: https://github.com/apache/hive/pull/5136#discussion_r1554570371


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -1611,7 +1612,68 @@ public SnapshotContext 
getCurrentSnapshotContext(org.apache.hadoop.hive.ql.metad
     if (current == null) {
       return null;
     }
-    return new SnapshotContext(current.snapshotId());
+    return toSnapshotContext(current);
+  }
+
+  private SnapshotContext toSnapshotContext(Snapshot snapshot) {
+    Map<String, String> summaryMap = snapshot.summary();
+    long addedRecords = getLongSummary(summaryMap, 
SnapshotSummary.ADDED_RECORDS_PROP);
+    long deletedRecords = getLongSummary(summaryMap, 
SnapshotSummary.DELETED_RECORDS_PROP);
+    return new SnapshotContext(
+        snapshot.snapshotId(), toWriteOperationType(snapshot.operation()), 
addedRecords, deletedRecords);
+  }
+
+  private SnapshotContext.WriteOperationType toWriteOperationType(String 
operation) {
+    if (DataOperations.APPEND.equals(operation)) {
+      return SnapshotContext.WriteOperationType.APPEND;
+    } else if (DataOperations.DELETE.equals(operation)) {
+      return SnapshotContext.WriteOperationType.DELETE;
+    } else if (DataOperations.OVERWRITE.equals(operation)) {
+      return SnapshotContext.WriteOperationType.OVERWRITE;
+    } else if (DataOperations.REPLACE.equals(operation)) {
+      return SnapshotContext.WriteOperationType.REPLACE;
+    } else {
+      return SnapshotContext.WriteOperationType.UNKNOWN;
+    }
+  }
+
+  private long getLongSummary(Map<String, String> summaryMap, String key) {
+    String textValue = summaryMap.get(key);
+    if (StringUtils.isBlank(textValue)) {
+      return 0;
+    }
+    return Long.parseLong(textValue);
+  }
+
+  @Override
+  public Iterable<SnapshotContext> getSnapshots(

Review Comment:
   @kasakrisz, would be nice to have some consistency in API names 



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