From 518dd51b2e831fa03646690c358db273d77a8038 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 9 Feb 2026 21:58:05 -0800 Subject: [PATCH] iceberg: simplify namespace properties normalization --- weed/s3api/iceberg/iceberg.go | 9 ++------- weed/s3api/iceberg/iceberg_namespace_properties_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/weed/s3api/iceberg/iceberg.go b/weed/s3api/iceberg/iceberg.go index a35a2ed90..9235cb6cb 100644 --- a/weed/s3api/iceberg/iceberg.go +++ b/weed/s3api/iceberg/iceberg.go @@ -402,15 +402,10 @@ func parsePagination(r *http.Request) (pageToken string, pageSize int, err error } func normalizeNamespaceProperties(properties map[string]string) map[string]string { - if len(properties) == 0 { + if properties == nil { return map[string]string{} } - - normalized := make(map[string]string, len(properties)) - for k, v := range properties { - normalized[k] = v - } - return normalized + return properties } // handleConfig returns catalog configuration. diff --git a/weed/s3api/iceberg/iceberg_namespace_properties_test.go b/weed/s3api/iceberg/iceberg_namespace_properties_test.go index f0cefaa63..fa80dc342 100644 --- a/weed/s3api/iceberg/iceberg_namespace_properties_test.go +++ b/weed/s3api/iceberg/iceberg_namespace_properties_test.go @@ -12,7 +12,7 @@ func TestNormalizeNamespacePropertiesNil(t *testing.T) { } } -func TestNormalizeNamespacePropertiesClonesInput(t *testing.T) { +func TestNormalizeNamespacePropertiesReturnsInputWhenSet(t *testing.T) { input := map[string]string{ "owner": "analytics", } @@ -22,8 +22,8 @@ func TestNormalizeNamespacePropertiesClonesInput(t *testing.T) { t.Fatalf("normalized properties value = %q, want %q", properties["owner"], "analytics") } - input["owner"] = "mutated" - if properties["owner"] != "analytics" { - t.Fatalf("normalized properties was mutated via input map") + input["owner"] = "updated" + if properties["owner"] != "updated" { + t.Fatalf("normalizeNamespaceProperties should reuse the input map when non-nil") } }