kasakrisz commented on code in PR #5136: URL: https://github.com/apache/hive/pull/5136#discussion_r1541088628
########## 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) { Review Comment: I like them after the method where they called first to easily scroll back to the caller. IMHO if the class is too big like this one their location doesn't add any value. ########## 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( + org.apache.hadoop.hive.ql.metadata.Table hmsTable, SnapshotContext since) { + + TableDesc tableDesc = Utilities.getTableDesc(hmsTable); + Table table = IcebergTableUtil.getTable(conf, tableDesc.getProperties()); + return getSnapshots(table.snapshots(), since); + } + + @VisibleForTesting + Iterable<SnapshotContext> getSnapshots(Iterable<Snapshot> snapshots, SnapshotContext since) { + List<SnapshotContext> result = Lists.newArrayList(); + + boolean foundSince = since == null; Review Comment: done -- 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