Skip to content

Schema.Equal does not compare schema metadata, but does compare field metadata #454

@lidavidm

Description

@lidavidm

Describe the enhancement requested

Equal does not compare the metadata.

arrow-go/arrow/schema.go

Lines 225 to 245 in 2900ed6

// Equal returns whether two schema are equal.
// Equal does not compare the metadata.
func (sc *Schema) Equal(o *Schema) bool {
switch {
case sc == o:
return true
case sc == nil || o == nil:
return false
case len(sc.fields) != len(o.fields):
return false
case sc.endianness != o.endianness:
return false
}
for i := range sc.fields {
if !sc.fields[i].Equal(o.fields[i]) {
return false
}
}
return true
}

But Field.Equal does compare the metadata:

func (f Field) Equal(o Field) bool {
switch {
case f.Name != o.Name:
return false
case f.Nullable != o.Nullable:
return false
case !TypeEqual(f.Type, o.Type, CheckMetadata()):
return false
case !f.Metadata.Equal(o.Metadata):
return false
}
return true
}

This is a little inconsistent. Ideally we would be able to choose how to compare. We could do the comparison ourselves but it's rather tedious, as we have to recurse into every type to find child fields. (Incidentally, if the DataType interface had a method to get the child fields (possibly empty) regardless of type, this would become much easier.)

Component(s)

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions