zeroshade commented on a change in pull request #10203: URL: https://github.com/apache/arrow/pull/10203#discussion_r630562673
########## File path: go/arrow/compare.go ########## @@ -46,34 +46,45 @@ func TypeEqual(left, right DataType, opts ...TypeEqualOption) bool { switch { case left == nil || right == nil: - return false + return left == nil && right == nil case left.ID() != right.ID(): return false } - // StructType is the only type that has metadata. - l, ok := left.(*StructType) - if !ok || cfg.metadata { - return reflect.DeepEqual(left, right) - } - - r := right.(*StructType) - switch { - case len(l.fields) != len(r.fields): - return false - case !reflect.DeepEqual(l.index, r.index): - return false - } - for i := range l.fields { - leftField, rightField := l.fields[i], r.fields[i] - switch { - case leftField.Name != rightField.Name: + switch l := left.(type) { + case ExtensionType: + return l.ExtensionEquals(right.(ExtensionType)) + case *ListType: + if !TypeEqual(l.Elem(), right.(*ListType).Elem(), opts...) { return false - case leftField.Nullable != rightField.Nullable: + } + if cfg.metadata { + return l.Meta.Equal(right.(*ListType).Meta) + } + return true + case *StructType: + r := right.(*StructType) + switch { + case len(l.fields) != len(r.fields): return false - case !TypeEqual(leftField.Type, rightField.Type, opts...): + case !reflect.DeepEqual(l.index, r.index): Review comment: it recursively goes through the objects to confirm that they are equal or not. if you look up at the deleted line 64 above this, I actually didn't change this logic at all despite what the diff shows. The diff isn't handling the changed order of the code well, but the previous code was already doing `!reflect.DeepEqual(l.index, r.index)` so there would be no change in logic from the existing setup for struct types here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org