From 717266ac15ef0a8754b89790c8be6fe35a2758b5 Mon Sep 17 00:00:00 2001 From: Willem Jan Noort Date: Tue, 10 Mar 2026 17:50:53 +0100 Subject: [PATCH] fix: add nullability to struct type String() --- arrow/avro/reader_test.go | 5 ++--- arrow/avro/schema_test.go | 10 ++++----- arrow/datatype_nested.go | 3 +++ arrow/util/protobuf_reflect_test.go | 32 ++++++++++++++--------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/arrow/avro/reader_test.go b/arrow/avro/reader_test.go index 9e4f36eb6..0eb513b34 100644 --- a/arrow/avro/reader_test.go +++ b/arrow/avro/reader_test.go @@ -101,9 +101,8 @@ func TestReader(t *testing.T) { ), }, arrow.Field{ - Name: "mapfield", - Type: arrow.MapOf(arrow.BinaryTypes.String, arrow.PrimitiveTypes.Int64), - Nullable: true, + Name: "mapfield", + Type: arrow.MapOf(arrow.BinaryTypes.String, arrow.PrimitiveTypes.Int64), }, arrow.Field{ Name: "arrayField", diff --git a/arrow/avro/schema_test.go b/arrow/avro/schema_test.go index d813da00e..921e5e815 100644 --- a/arrow/avro/schema_test.go +++ b/arrow/avro/schema_test.go @@ -83,9 +83,8 @@ func TestSchemaStringEqual(t *testing.T) { Name: "person", Type: arrow.StructOf( arrow.Field{ - Name: "lastname", - Type: arrow.BinaryTypes.String, - Nullable: true, + Name: "lastname", + Type: arrow.BinaryTypes.String, }, arrow.Field{ Name: "address", @@ -101,9 +100,8 @@ func TestSchemaStringEqual(t *testing.T) { ), }, arrow.Field{ - Name: "mapfield", - Type: arrow.MapOf(arrow.BinaryTypes.String, arrow.PrimitiveTypes.Int64), - Nullable: true, + Name: "mapfield", + Type: arrow.MapOf(arrow.BinaryTypes.String, arrow.PrimitiveTypes.Int64), }, arrow.Field{ Name: "arrayField", diff --git a/arrow/datatype_nested.go b/arrow/datatype_nested.go index 6664c505b..fd855d67f 100644 --- a/arrow/datatype_nested.go +++ b/arrow/datatype_nested.go @@ -444,6 +444,9 @@ func (t *StructType) String() string { o.WriteString(", ") } o.WriteString(fmt.Sprintf("%s: %v", f.Name, f.Type)) + if f.Nullable { + o.WriteString(" nullable") + } } o.WriteString(">") return o.String() diff --git a/arrow/util/protobuf_reflect_test.go b/arrow/util/protobuf_reflect_test.go index 38297bb2d..35ef15692 100644 --- a/arrow/util/protobuf_reflect_test.go +++ b/arrow/util/protobuf_reflect_test.go @@ -119,14 +119,14 @@ func AllTheTypesFixture() Fixture { - bytes: type=binary, nullable - double: type=float64, nullable - enum: type=dictionary, nullable - - message: type=struct, nullable + - message: type=struct, nullable - oneofstring: type=utf8, nullable - - oneofmessage: type=struct, nullable - - any: type=struct, nullable + - oneofmessage: type=struct, nullable + - any: type=struct, nullable - simple_map: type=map, nullable - - complex_map: type=map, items_nullable>, nullable + - complex_map: type=map, items_nullable>, nullable - simple_list: type=list, nullable - - complex_list: type=list, nullable>, nullable` + - complex_list: type=list, nullable>, nullable` return Fixture{ msg: &msg, @@ -255,13 +255,13 @@ func TestGetSchema(t *testing.T) { - bytes: type=binary, nullable - double: type=float64, nullable - enum: type=dictionary, nullable - - message: type=struct, nullable - - oneof: type=dense_union, nullable=1>, nullable - - any: type=struct, nullable + - message: type=struct, nullable + - oneof: type=dense_union, nullable=1>, nullable + - any: type=struct, nullable - simple_map: type=map, nullable - - complex_map: type=map, items_nullable>, nullable + - complex_map: type=map, items_nullable>, nullable - simple_list: type=list, nullable - - complex_list: type=list, nullable>, nullable` + - complex_list: type=list, nullable>, nullable` CheckSchema(t, pmr, want) excludeComplex := func(pfr *ProtobufFieldReflection) bool { @@ -386,8 +386,8 @@ func TestExcludedNested(t *testing.T) { } schema := `schema: fields: 2 - - simple_a: type=list, nullable>, nullable - - simple_b: type=list, nullable>, nullable` + - simple_a: type=list, nullable>, nullable + - simple_b: type=list, nullable>, nullable` simpleNested := util_message.SimpleNested{ SimpleA: []*util_message.ExampleMessage{&msg}, @@ -415,8 +415,8 @@ func TestExcludedNested(t *testing.T) { f := AllTheTypesNoAnyFixture() schema = `schema: fields: 2 - - all_the_types_no_any_a: type=list, message: struct, oneofstring: utf8, oneofmessage: struct, simple_map: map, complex_map: map, items_nullable>, simple_list: list, complex_list: list, nullable>>, nullable>, nullable - - all_the_types_no_any_b: type=list, message: struct, oneofstring: utf8, oneofmessage: struct, simple_map: map, complex_map: map, items_nullable>, simple_list: list, complex_list: list, nullable>>, nullable>, nullable` + - all_the_types_no_any_a: type=list nullable, message: struct nullable, oneofstring: utf8 nullable, oneofmessage: struct nullable, simple_map: map nullable, complex_map: map, items_nullable> nullable, simple_list: list nullable, complex_list: list, nullable> nullable>, nullable>, nullable + - all_the_types_no_any_b: type=list nullable, message: struct nullable, oneofstring: utf8 nullable, oneofmessage: struct nullable, simple_map: map nullable, complex_map: map, items_nullable> nullable, simple_list: list nullable, complex_list: list, nullable> nullable>, nullable>, nullable` complexNested := util_message.ComplexNested{ AllTheTypesNoAnyA: []*util_message.AllTheTypesNoAny{f.msg.(*util_message.AllTheTypesNoAny)}, @@ -445,8 +445,8 @@ func TestExcludedNested(t *testing.T) { schema = `schema: fields: 2 - - complex_nested: type=struct, message: struct, oneofstring: utf8, oneofmessage: struct, simple_map: map, complex_map: map, items_nullable>, simple_list: list, complex_list: list, nullable>>, nullable>, all_the_types_no_any_b: list, message: struct, oneofstring: utf8, oneofmessage: struct, simple_map: map, complex_map: map, items_nullable>, simple_list: list, complex_list: list, nullable>>, nullable>>, nullable - - simple_nested: type=struct, nullable>, simple_b: list, nullable>>, nullable` + - complex_nested: type=struct nullable, message: struct nullable, oneofstring: utf8 nullable, oneofmessage: struct nullable, simple_map: map nullable, complex_map: map, items_nullable> nullable, simple_list: list nullable, complex_list: list, nullable> nullable>, nullable> nullable, all_the_types_no_any_b: list nullable, message: struct nullable, oneofstring: utf8 nullable, oneofmessage: struct nullable, simple_map: map nullable, complex_map: map, items_nullable> nullable, simple_list: list nullable, complex_list: list, nullable> nullable>, nullable> nullable>, nullable + - simple_nested: type=struct, nullable> nullable, simple_b: list, nullable> nullable>, nullable` deepNested := util_message.DeepNested{ ComplexNested: &complexNested,