You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/29 23:30:05 UTC

[GitHub] [iceberg] szehon-ho commented on a diff in pull request #3457: Spark: Improve performance of expire snapshot by not double-scanning retained Snapshots

szehon-ho commented on code in PR #3457:
URL: https://github.com/apache/iceberg/pull/3457#discussion_r933684634


##########
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/actions/ExpireSnapshotsSparkAction.java:
##########
@@ -171,11 +173,15 @@ public Dataset<Row> expire() {
 
       expireSnapshots.commit();
 
-      // fetch metadata after expiration
-      Dataset<Row> validFiles = buildValidFileDF(ops.refresh());
+      TableMetadata updatedTable = ops.refresh();
+      Set<Long> retainedSnapshots =
+          updatedTable.snapshots().stream().map(Snapshot::snapshotId).collect(Collectors.toSet());
+      Dataset<Row> validFiles = buildValidFileDF(updatedTable);
+      Dataset<Row> deleteCandidateFiles =

Review Comment:
   Sure, it makes sense to me, can make the change.
   
   I had the optimization in the end to pass the lesser of the two sets to Spark , with either 'in' or 'not in', but can still do it the other way.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org