gaborkaszab commented on code in PR #12401: URL: https://github.com/apache/iceberg/pull/12401#discussion_r1981338121
########## core/src/main/java/org/apache/iceberg/view/ViewMetadata.java: ########## @@ -462,9 +463,18 @@ public ViewMetadata build() { ViewProperties.VERSION_HISTORY_SIZE, historySize); - // expire old versions, but keep at least the versions added in this builder - int numAddedVersions = (int) changes(MetadataUpdate.AddViewVersion.class).count(); - int numVersionsToKeep = Math.max(numAddedVersions, historySize); + // expire old versions, but keep at least the versions added in this builder and the current + // version + int numVersions = + ImmutableSet.builder() + .addAll( + changes(MetadataUpdate.AddViewVersion.class) + .map(v -> v.viewVersion().versionId()) + .collect(Collectors.toSet())) + .add(currentVersionId) + .build() + .size(); Review Comment: Yes, I also think we need a set here in here. My original comment was to avoid introducing 2 sets as the code was doing so, one is enough instead. -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org