lliangyu-lin commented on code in PR #12401: URL: https://github.com/apache/iceberg/pull/12401#discussion_r1980313203
########## core/src/main/java/org/apache/iceberg/view/ViewMetadata.java: ########## @@ -462,9 +463,15 @@ 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 + Set<Integer> addedVersions = + changes(MetadataUpdate.AddViewVersion.class) + .map(v -> v.viewVersion().versionId()) + .collect(Collectors.toSet()); + int numVersions = + ImmutableSet.builder().addAll(addedVersions).add(currentVersionId).build().size(); Review Comment: Thanks for the review. I made a minor change to combine the set and also since we just need the size, there is no set left around. I'm not sure if a function will be needed in this case. -- 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