You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ze...@apache.org on 2026/04/07 20:10:29 UTC

(iceberg-go) branch main updated: feat(table): Add OpReplace to updateSnapshotSummaries (#853)

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 b4722bb1 feat(table): Add OpReplace to updateSnapshotSummaries (#853)
b4722bb1 is described below

commit b4722bb1f1a43160598e6d469810173bf5d92d87
Author: Dao Thanh Tung <tt...@accountancy.smu.edu.sg>
AuthorDate: Tue Apr 7 21:10:23 2026 +0100

    feat(table): Add OpReplace to updateSnapshotSummaries (#853)
    
    Fixes: https://github.com/apache/iceberg-go/issues/840
    
    Signed-off-by: dttung2905 <tt...@accountancy.smu.edu.sg>
---
 table/snapshots.go               |  2 +-
 table/snapshots_internal_test.go | 66 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/table/snapshots.go b/table/snapshots.go
index 1ae60e52..eb8196a4 100644
--- a/table/snapshots.go
+++ b/table/snapshots.go
@@ -465,7 +465,7 @@ func (s *SnapshotSummaryCollector) build() iceberg.Properties {
 
 func updateSnapshotSummaries(sum Summary, previous iceberg.Properties) (Summary, error) {
 	switch sum.Operation {
-	case OpAppend, OpOverwrite, OpDelete:
+	case OpAppend, OpOverwrite, OpDelete, OpReplace:
 	default:
 		return sum, fmt.Errorf("%w: operation: %s", iceberg.ErrNotImplemented, sum.Operation)
 	}
diff --git a/table/snapshots_internal_test.go b/table/snapshots_internal_test.go
index f87f721f..488287f8 100644
--- a/table/snapshots_internal_test.go
+++ b/table/snapshots_internal_test.go
@@ -142,6 +142,68 @@ func TestMergeSnapshotSummaries(t *testing.T) {
 				"total-equality-deletes": "3",
 			}},
 		},
+		{
+			Summary{Operation: OpReplace},
+			nil, false,
+			Summary{Operation: OpReplace, Properties: iceberg.Properties{
+				"total-data-files":       "0",
+				"total-delete-files":     "0",
+				"total-records":          "0",
+				"total-files-size":       "0",
+				"total-position-deletes": "0",
+				"total-equality-deletes": "0",
+			}},
+		},
+		{
+			Summary{Operation: OpReplace, Properties: iceberg.Properties{
+				"added-data-files":       "1",
+				"added-delete-files":     "2",
+				"added-equality-deletes": "3",
+				"added-files-size":       "4",
+				"added-position-deletes": "5",
+				"added-records":          "6",
+			}},
+			nil, false,
+			Summary{Operation: OpReplace, Properties: iceberg.Properties{
+				"added-data-files":       "1",
+				"added-delete-files":     "2",
+				"added-equality-deletes": "3",
+				"added-files-size":       "4",
+				"added-position-deletes": "5",
+				"added-records":          "6",
+				"total-data-files":       "1",
+				"total-delete-files":     "2",
+				"total-records":          "6",
+				"total-files-size":       "4",
+				"total-position-deletes": "5",
+				"total-equality-deletes": "3",
+			}},
+		},
+		{
+			Summary{Operation: OpReplace, Properties: iceberg.Properties{
+				"added-data-files":   "1",
+				"deleted-data-files": "1",
+			}},
+			iceberg.Properties{
+				"total-data-files":       "10",
+				"total-delete-files":     "0",
+				"total-records":          "0",
+				"total-files-size":       "0",
+				"total-position-deletes": "0",
+				"total-equality-deletes": "0",
+			},
+			false,
+			Summary{Operation: OpReplace, Properties: iceberg.Properties{
+				"added-data-files":       "1",
+				"deleted-data-files":     "1",
+				"total-data-files":       "10",
+				"total-delete-files":     "0",
+				"total-records":          "0",
+				"total-files-size":       "0",
+				"total-position-deletes": "0",
+				"total-equality-deletes": "0",
+			}},
+		},
 	}
 
 	for _, tt := range tests {
@@ -151,7 +213,7 @@ func TestMergeSnapshotSummaries(t *testing.T) {
 	}
 }
 
-func TestInvalidOperation(t *testing.T) {
-	_, err := updateSnapshotSummaries(Summary{Operation: OpReplace}, nil)
+func TestUpdateSnapshotSummariesUnsupportedOperation(t *testing.T) {
+	_, err := updateSnapshotSummaries(Summary{Operation: Operation("scan")}, nil)
 	assert.ErrorIs(t, err, iceberg.ErrNotImplemented)
 }