This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new 5a9607c6 fix(table): find min seq correctly from manifest list (#693)
5a9607c6 is described below
commit 5a9607c6f1c32da5a93837902b3cc9d14ee4d974
Author: ferhat elmas <[email protected]>
AuthorDate: Fri Jan 23 16:12:12 2026 +0100
fix(table): find min seq correctly from manifest list (#693)
Signed-off-by: ferhat elmas <[email protected]>
---
table/scanner.go | 6 ++-
table/scanner_internal_test.go | 102 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+), 1 deletion(-)
diff --git a/table/scanner.go b/table/scanner.go
index 19be24b5..8dfc238e 100644
--- a/table/scanner.go
+++ b/table/scanner.go
@@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"iter"
+ "math"
"slices"
"sync"
@@ -272,12 +273,15 @@ func (scan *Scan) checkSequenceNumber(minSeqNum int64,
manifest iceberg.Manifest
}
func minSequenceNum(manifests []iceberg.ManifestFile) int64 {
- n := int64(0)
+ var n int64 = math.MaxInt64
for _, m := range manifests {
if m.ManifestContent() == iceberg.ManifestContentData {
n = min(n, m.MinSequenceNum())
}
}
+ if n == math.MaxInt64 {
+ return 0
+ }
return n
}
diff --git a/table/scanner_internal_test.go b/table/scanner_internal_test.go
new file mode 100644
index 00000000..f0813fc9
--- /dev/null
+++ b/table/scanner_internal_test.go
@@ -0,0 +1,102 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package table
+
+import (
+ "testing"
+
+ "github.com/apache/iceberg-go"
+ "github.com/stretchr/testify/assert"
+)
+
+func newDataManifest(minSeqNum int64) iceberg.ManifestFile {
+ return iceberg.NewManifestFile(2, "/path/to/manifest.avro", 1000, 0, 1).
+ Content(iceberg.ManifestContentData).
+ SequenceNum(minSeqNum, minSeqNum).
+ Build()
+}
+
+func newDeleteManifest(minSeqNum int64) iceberg.ManifestFile {
+ return iceberg.NewManifestFile(2, "/path/to/manifest.avro", 1000, 0, 1).
+ Content(iceberg.ManifestContentDeletes).
+ SequenceNum(minSeqNum, minSeqNum).
+ Build()
+}
+
+func TestMinSequenceNum(t *testing.T) {
+ tests := []struct {
+ name string
+ manifests []iceberg.ManifestFile
+ expected int64
+ }{
+ {
+ name: "empty list returns 0",
+ manifests: []iceberg.ManifestFile{},
+ expected: 0,
+ },
+ {
+ name: "single data manifest returns its sequence
number",
+ manifests: []iceberg.ManifestFile{
+ newDataManifest(5),
+ },
+ expected: 5,
+ },
+ {
+ name: "multiple data manifests returns minimum",
+ manifests: []iceberg.ManifestFile{
+ newDataManifest(10),
+ newDataManifest(3),
+ newDataManifest(7),
+ },
+ expected: 3,
+ },
+ {
+ name: "only delete manifests returns 0",
+ manifests: []iceberg.ManifestFile{
+ newDeleteManifest(5),
+ newDeleteManifest(10),
+ },
+ expected: 0,
+ },
+ {
+ name: "mixed manifests only considers data manifests",
+ manifests: []iceberg.ManifestFile{
+ newDeleteManifest(1), // should be ignored
+ newDataManifest(8),
+ newDeleteManifest(2), // should be ignored
+ newDataManifest(5),
+ },
+ expected: 5,
+ },
+ {
+ name: "data manifest with sequence 0 is handled
correctly",
+ manifests: []iceberg.ManifestFile{
+ newDataManifest(0),
+ newDataManifest(5),
+ },
+ expected: 0,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := minSequenceNum(tt.manifests)
+ assert.Equal(t, tt.expected, result)
+ })
+ }
+}