This is an automated email from the ASF dual-hosted git repository. zeroshade pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push: new de6e537e51 MINOR: [Go][ipc] Fix typeFromFB (#33905) de6e537e51 is described below commit de6e537e51a99d62d7fed3c3fe0eac646bf70e05 Author: coldWater <254244...@qq.com> AuthorDate: Tue Jan 31 00:37:43 2023 +0800 MINOR: [Go][ipc] Fix typeFromFB (#33905) ### Rationale for this change Fix typeFromFB for map type with non-nullable items ### Are these changes tested? yes ### Are there any user-facing changes? bug fix Authored-by: coldWater <forsaken...@gamil.com> Signed-off-by: Matt Topol <zotthewiz...@gmail.com> --- go/arrow/datatype_nested.go | 5 +++++ go/arrow/datatype_nested_test.go | 4 ++-- go/arrow/ipc/ipc_test.go | 2 +- go/arrow/ipc/metadata.go | 1 + go/arrow/ipc/metadata_test.go | 4 ++++ go/arrow/scalar/scalar_test.go | 2 +- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/go/arrow/datatype_nested.go b/go/arrow/datatype_nested.go index 06cb735555..049cd2d11e 100644 --- a/go/arrow/datatype_nested.go +++ b/go/arrow/datatype_nested.go @@ -346,6 +346,11 @@ func (t *MapType) String() string { if t.KeysSorted { o.WriteString(", keys_sorted") } + if t.ItemField().Nullable { + o.WriteString(", items_nullable") + } else { + o.WriteString(", items_non_nullable") + } o.WriteString(">") return o.String() } diff --git a/go/arrow/datatype_nested_test.go b/go/arrow/datatype_nested_test.go index 736f2b14cd..4783dc290a 100644 --- a/go/arrow/datatype_nested_test.go +++ b/go/arrow/datatype_nested_test.go @@ -368,7 +368,7 @@ func TestMapOf(t *testing.T) { Field{Name: "key", Type: BinaryTypes.String}, Field{Name: "value", Type: PrimitiveTypes.Uint8, Nullable: true}, ))}, - str: "map<utf8, uint8>", + str: "map<utf8, uint8, items_nullable>", }, { key: BinaryTypes.String, @@ -381,7 +381,7 @@ func TestMapOf(t *testing.T) { Field{Name: "value", Type: FixedWidthTypes.Date32, Nullable: true}, ))}}, ))}, - str: "map<utf8, map<uint32, date32>>", + str: "map<utf8, map<uint32, date32, items_nullable>, items_nullable>", }, } { t.Run("", func(t *testing.T) { diff --git a/go/arrow/ipc/ipc_test.go b/go/arrow/ipc/ipc_test.go index 0a9a571cf0..f5f29fdf76 100644 --- a/go/arrow/ipc/ipc_test.go +++ b/go/arrow/ipc/ipc_test.go @@ -533,7 +533,7 @@ func Example_mapSlice() { // record: // schema: // fields: 1 - // - map: type=map<utf8, utf8> + // - map: type=map<utf8, utf8, items_nullable> // rows: 1 // col[0][map]: [{["index3" "tag_int"] ["main4" ""]}] } diff --git a/go/arrow/ipc/metadata.go b/go/arrow/ipc/metadata.go index c36379f3cd..10caf2e3c7 100644 --- a/go/arrow/ipc/metadata.go +++ b/go/arrow/ipc/metadata.go @@ -793,6 +793,7 @@ func concreteTypeFromFB(typ flatbuf.Type, data flatbuffers.Table, children []arr var dt flatbuf.Map dt.Init(data.Bytes, data.Pos) ret := arrow.MapOf(pairType.Field(0).Type, pairType.Field(1).Type) + ret.SetItemNullable(pairType.Field(1).Nullable) ret.KeysSorted = dt.KeysSorted() return ret, nil diff --git a/go/arrow/ipc/metadata_test.go b/go/arrow/ipc/metadata_test.go index 4575c163b9..805b1c5e1e 100644 --- a/go/arrow/ipc/metadata_test.go +++ b/go/arrow/ipc/metadata_test.go @@ -33,6 +33,9 @@ import ( func TestRWSchema(t *testing.T) { meta := arrow.NewMetadata([]string{"k1", "k2", "k3"}, []string{"v1", "v2", "v3"}) + + mType := arrow.MapOf(arrow.BinaryTypes.String, arrow.BinaryTypes.String) + mType.SetItemNullable(false) for _, tc := range []struct { schema *arrow.Schema memo dictutils.Memo @@ -42,6 +45,7 @@ func TestRWSchema(t *testing.T) { {Name: "f1", Type: arrow.PrimitiveTypes.Int64}, {Name: "f2", Type: arrow.PrimitiveTypes.Uint16}, {Name: "f3", Type: arrow.PrimitiveTypes.Float64}, + {Name: "f4", Type: mType}, }, &meta), memo: dictutils.Memo{}, }, diff --git a/go/arrow/scalar/scalar_test.go b/go/arrow/scalar/scalar_test.go index 6d07b70d5c..4b412256d4 100644 --- a/go/arrow/scalar/scalar_test.go +++ b/go/arrow/scalar/scalar_test.go @@ -965,7 +965,7 @@ func TestToScalar(t *testing.T) { expected := `{field_names:list<item: utf8, nullable> = ["foo" "bar" "baz"], ` + `field_null:list<item: bool, nullable> = [true false], ` + - `field_metadata:list<item: map<binary, binary>, nullable> = ` + + `field_metadata:list<item: map<binary, binary, items_nullable>, nullable> = ` + `[{["captain" "option" "souper"] ["planet" "val" "bowl"]} {[] []} {["captain" "option" "souper"] ["planet" "val" "bowl"]}], ` + `val8:list<item: int8, nullable> = [1 2 3 4], ` + `u8:list<item: uint8, nullable> = [5 6], ` +