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/arrow-go.git


The following commit(s) were added to refs/heads/main by this push:
     new ad7125ac fix: Metadata.Equal comparison with keys in different order 
(#571)
ad7125ac is described below

commit ad7125ac75c53512ae4f6ded137568eb34f40774
Author: Matt Topol <[email protected]>
AuthorDate: Tue Nov 11 10:00:42 2025 -0500

    fix: Metadata.Equal comparison with keys in different order (#571)
    
    ### Rationale for this change
    fixes #565
    
    ### What changes are included in this PR?
    Fixing `Metadata.sortedIndices` to properly sort the key indices
    
    ### Are these changes tested?
    Yes, a unit test is added for this situation
    
    ### Are there any user-facing changes?
    No
---
 arrow/schema.go      |  2 +-
 arrow/schema_test.go | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arrow/schema.go b/arrow/schema.go
index a9802165..1e9e6414 100644
--- a/arrow/schema.go
+++ b/arrow/schema.go
@@ -130,7 +130,7 @@ func (md Metadata) sortedIndices() []int {
        }
 
        slices.SortFunc(idxes, func(i, j int) int {
-               return strings.Compare(md.keys[idxes[i]], md.keys[idxes[j]])
+               return strings.Compare(md.keys[i], md.keys[j])
        })
        return idxes
 }
diff --git a/arrow/schema_test.go b/arrow/schema_test.go
index 48e164a1..3cc7b374 100644
--- a/arrow/schema_test.go
+++ b/arrow/schema_test.go
@@ -149,6 +149,18 @@ func TestMetadata(t *testing.T) {
        })
 }
 
+func TestMetadataSortedIndices(t *testing.T) {
+       md1 := NewMetadata(
+               []string{"..", "a", "b", "c", "A", "B", "C"},
+               []string{"1", "2", "3", "4", "5", "6", "7"})
+
+       md2 := NewMetadata(
+               []string{"A", "B", "C", "..", "a", "b", "c"},
+               []string{"5", "6", "7", "1", "2", "3", "4"})
+
+       assert.True(t, md1.Equal(md2))
+}
+
 func TestSchema(t *testing.T) {
        for _, tc := range []struct {
                fields    []Field

Reply via email to