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/01/21 07:22:53 UTC

[GitHub] [iceberg] jackye1995 commented on issue #3900: Deprecate TableMetadata.removeSnapshotsIf in favor of metadata builder

jackye1995 commented on issue #3900:
URL: https://github.com/apache/iceberg/issues/3900#issuecomment-1018248216


   Overall there are 3 use cases:
   1. filter snapshots with ref and skip removal of those
   2. throw exception if a snapshot to remove has ref
   3. directly remove snapshot and its associated refs
   
   Consider the use case if this method, it is basically used for snapshot expiration and nothing else. The logic is:
   
   ```java
       TableMetadata updateMeta = base.removeSnapshotsIf(snapshot ->
           idsToRemove.contains(snapshot.snapshotId()) ||
           (snapshot.timestampMillis() < expireOlderThan && !idsToRetain.contains(snapshot.snapshotId())));
   ```
   
   When we add branching and tagging, we will have a much more complex if statement to filter out snapshots, and we should be sure that the snapshots passed into the method are the ones we truly want to remove. The snapshot might have associated refs, but removing the refs along the way seems like the correct choice, so that we don't need to have another operation like `RemoveSnapshotRef` to clean those things up.
   
   Based on this, I think option 3 makes sense to me at this point of time based on the use case.
   
   This is also not a one way door, we can always add a flag to achieve 1 or 2 in the future if that is absolutely needed, but it should be simpler to enforce that requirement before the information is passed into the method.


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