Skip to content

Core: Allow write.metadata.previous-versions-max to be 0#16796

Open
smaheshwar-pltr wants to merge 4 commits into
apache:mainfrom
smaheshwar-pltr:previous-versions-max-zero
Open

Core: Allow write.metadata.previous-versions-max to be 0#16796
smaheshwar-pltr wants to merge 4 commits into
apache:mainfrom
smaheshwar-pltr:previous-versions-max-zero

Conversation

@smaheshwar-pltr

@smaheshwar-pltr smaheshwar-pltr commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes #16797, if folks are aligned with that feature request in the first place (please let me know your thoughts there!)

@smaheshwar-pltr smaheshwar-pltr marked this pull request as ready for review June 12, 2026 22:22
@smaheshwar-pltr smaheshwar-pltr marked this pull request as draft June 12, 2026 22:24
| write.summary.partition-limit | 0 | Includes partition-level summary stats in snapshot summaries if the changed partition count is less than this limit |
| write.metadata.delete-after-commit.enabled | false | Controls whether to delete the oldest **tracked** version metadata files after each table commit. See the [Remove old metadata files](maintenance.md#remove-old-metadata-files) section for additional details |
| write.metadata.previous-versions-max | 100 | The max number of previous version metadata files to track |
| write.metadata.previous-versions-max | 100 | The max number of previous version metadata files to track. A value of `0` keeps no previous metadata files (an empty `metadata-log`) |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing out that I'm not including a spec change in this PR because I kind of think

A list (optional) of timestamp and metadata file location pairs that encodes changes to the previous metadata files for the table. Each time a new metadata file is created, a new entry of the previous metadata file location should be added to the list. Tables can be configured to remove oldest metadata log entries and keep a fixed-size log of the most recent entries after a commit.

from https://iceberg.apache.org/spec/#table-metadata is worded consistently with a value of 0?

@smaheshwar-pltr smaheshwar-pltr marked this pull request as ready for review June 12, 2026 22:35
@smaheshwar-pltr smaheshwar-pltr marked this pull request as draft June 13, 2026 02:30
smaheshwar-pltr added a commit to smaheshwar-pltr/iceberg that referenced this pull request Jun 13, 2026
…ded-file delete

Addresses review on PR apache#16796: drop the trackedMetadataFiles helper and restore
the original entry-level removeAll (MetadataLogEntry equality) over
Sets.newHashSet(base.previousFiles()), with the original comment. The max=0
behaviour is now an explicitly-guarded additive step: delete base's superseded
metadata file only when the new metadata no longer references it (not its
current location and not in its log). This keeps the method a no-op for
previous-versions-max >= 1 and for base == metadata (a public-API contract the
helper version regressed), and is null-safe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
smaheshwar-pltr and others added 2 commits June 13, 2026 04:15
Pins the public-API contract that the superseded-file deletion must never
remove the live current metadata file: with base and metadata sharing a
location and an empty log (the previous-versions-max=0 shape), nothing is
deleted. This guards the !superseded.equals(metadata.metadataFileLocation())
condition, which no existing test covered. The null-base-location path is
already exercised by noFailureWhenBulkDeletingMetadataFiles, so no separate
test is added for it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@smaheshwar-pltr smaheshwar-pltr force-pushed the previous-versions-max-zero branch from 85e3b32 to 98ea1dd Compare June 13, 2026 03:15
@smaheshwar-pltr smaheshwar-pltr marked this pull request as ready for review June 13, 2026 03:58
int maxSize =
Math.max(
1,
0,

@smaheshwar-pltr smaheshwar-pltr Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing out that a negative value for this property now corresponds to an empty log - previously, it was a log of maximum size one. This is technically a break, but that felt fine to me?

@smaheshwar-pltr smaheshwar-pltr changed the title Core: Allow write.metadata.previous-versions-max of 0 Core: Allow write.metadata.previous-versions-max to be 0 Jun 13, 2026
Comment thread core/src/test/java/org/apache/iceberg/TestCatalogUtil.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allowwrite.metadata.previous-versions-max table property to be 0 for empty metadata logs

1 participant