Skip to content

fix(table): find min seq correctly from manifest list - #693

Merged
zeroshade merged 1 commit into
apache:mainfrom
ferhatelmas:manifest-list-min-seq
Jan 23, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
ferhatelmas:manifest-list-min-seq

Conversation

@ferhatelmas

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread table/scanner.go Outdated
Comment on lines 275 to 277
var n int64
found := false
for _, m := range manifests {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is the found variable needed? what test scenario is different with this change from what it was before?

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.

It could cause wrong delete manifests to apply because old code always returns zero due to wrong initial condition. found enables setting it unconditionally at first.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The zero value of int64 is still 0, so this doesn't functionally change anything. You'd have to initialize n to -1 or something that would designate an invalid seq number

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.

n is set to first value in the first iteration because found is false then we keep applying min. Previously, it was set to zero and zero is already minimum value so it doesn't change with manifest version where it should have been.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I see what you mean. I feel like we could initialize n to INT_MAX to fix it and simplify, right? Something like...

n := math.MaxInt64
for _, m := range manifests {
    if m.ManifestContent() == iceberg.ManifestContentData {
        n = min(n, m.MinSequenceNum())
    }
}

if n == math.MaxInt64 {
    n = 0
}

return n

I find that simpler to read than having the found check. Make sense?

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.

I didn't want to import math at first but yes, it works as well. Updated so

@ferhatelmas
ferhatelmas force-pushed the manifest-list-min-seq branch from ec6ea0c to 0cf2c4c Compare January 23, 2026 11:47

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@zeroshade
zeroshade merged commit 5a9607c into apache:main Jan 23, 2026
11 checks passed
@ferhatelmas
ferhatelmas deleted the manifest-list-min-seq branch January 23, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants