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 170be776b fix(view): compare metadata properties (#2464)
170be776b is described below
commit 170be776b9a9aa93a8dc22a3e61a60b23819999f
Author: Minh Vu <[email protected]>
AuthorDate: Mon Nov 9 20:21:40 2026 +0100
fix(view): compare metadata properties (#2464)
---
view/metadata.go | 3 ++-
view/metadata_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
view/view_test.go | 13 +++++++++++++
3 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/view/metadata.go b/view/metadata.go
index bf84f14b4..840fc79e9 100644
--- a/view/metadata.go
+++ b/view/metadata.go
@@ -361,7 +361,8 @@ func (m *metadata) Equals(other Metadata) bool {
iceinternal.SliceEqualHelper(m.Schemas(), other.Schemas()) &&
iceinternal.SliceEqualHelper(m.Versions(), other.Versions()) &&
m.CurrentVersionIDValue == other.CurrentVersionID() &&
- slices.Equal(m.VersionLogList, other.VersionLog())
+ slices.Equal(m.VersionLogList, other.VersionLog()) &&
+ maps.Equal(m.Props, other.Properties())
}
func (m *metadata) FormatVersion() int { return m.FormatVersionValue }
diff --git a/view/metadata_test.go b/view/metadata_test.go
index 953fb4c93..2e2a23940 100644
--- a/view/metadata_test.go
+++ b/view/metadata_test.go
@@ -69,6 +69,56 @@ func TestVersionEquals(t *testing.T) {
assert.True(t, v1.Equals(v2), fmt.Sprintf("Expected the same SchemaID,
Summary, Representation for %v, got %v", v1, v2))
}
+func TestMetadataEqualsIncludesProperties(t *testing.T) {
+ parsed, err := ParseMetadataString(exampleViewJSON)
+ require.NoError(t, err)
+
+ base := parsed.(*metadata)
+ base.Props = iceberg.Properties{
+ "comment": "daily report",
+ VersionHistorySizeKey: "10",
+ }
+ base.init()
+
+ tests := []struct {
+ name string
+ props iceberg.Properties
+ wantEqual bool
+ }{
+ {
+ name: "same properties",
+ props: iceberg.Properties{"comment": "daily
report", VersionHistorySizeKey: "10"},
+ wantEqual: true,
+ },
+ {
+ name: "added property",
+ props: iceberg.Properties{"comment": "daily report",
VersionHistorySizeKey: "10", "owner": "analytics"},
+ },
+ {
+ name: "removed property",
+ props: iceberg.Properties{"comment": "daily report"},
+ },
+ {
+ name: "changed property",
+ props: iceberg.Properties{"comment": "weekly report",
VersionHistorySizeKey: "10"},
+ },
+ {
+ name: "changed version history size",
+ props: iceberg.Properties{"comment": "daily report",
VersionHistorySizeKey: "20"},
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ other := *base
+ other.Props = tt.props
+ other.init()
+
+ assert.Equal(t, tt.wantEqual, base.Equals(&other))
+ })
+ }
+}
+
func TestNewRepresentationSetsTypeWithoutMutatingInput(t *testing.T) {
input := Representation{SQL: "SELECT 1", Dialect: "spark"}
repr := NewRepresentation(input)
diff --git a/view/view_test.go b/view/view_test.go
index 0a9d29a35..3d0f11ba7 100644
--- a/view/view_test.go
+++ b/view/view_test.go
@@ -90,6 +90,19 @@ func (t *ViewTestSuite) TestNewViewFromReadFile() {
t.True(t.view.Equals(*vw2))
}
+func (t *ViewTestSuite) TestEqualsIncludesMetadataProperties() {
+ originalMetadata := t.view.metadata.(*metadata)
+ otherMetadata := *originalMetadata
+ otherMetadata.Props = originalMetadata.Properties()
+ otherMetadata.Props["comment"] = "different comment"
+ otherMetadata.init()
+
+ otherView := *t.view
+ otherView.metadata = &otherMetadata
+
+ t.False(t.view.Equals(otherView))
+}
+
func (t *ViewTestSuite) TestCreateViewJoinsTrailingSlashMetadataLocation() {
createdView, err := CreateView(
t.T().Context(),