zeroshade commented on code in PR #1704:
URL: https://github.com/apache/arrow-go/pull/1704#discussion_r4742983963
##########
arrow/compute/cast_test.go:
##########
@@ -3991,6 +3991,53 @@ func TestCasts(t *testing.T) {
suite.Run(t, new(CastSuite))
}
+func TestCastToStringReleasesBuilderArray(t *testing.T) {
Review Comment:
nit: the name describes the fix rather than the behaviour. Something like
`TestCastToStringNoLeak` would read better.
Also, as the description says, the underlying gap is that `checkCast` runs
with `context.Background()`. Passing `compute.WithAllocator(ctx, suite.mem)`
through `checkCast` would make the whole `CastSuite` check for leaks. That
would probably surface more (e.g. the `fixed_size_binary` case), so it fits
better as a separate PR.
##########
arrow/compute/cast_test.go:
##########
@@ -3991,6 +3991,53 @@ func TestCasts(t *testing.T) {
suite.Run(t, new(CastSuite))
}
+func TestCastToStringReleasesBuilderArray(t *testing.T) {
+ tests := []struct {
+ dt arrow.DataType
+ inJSON, outJSON string
+ }{
+ {arrow.FixedWidthTypes.Boolean, `[true, null, false]`,
`["true", null, "false"]`},
+ {arrow.PrimitiveTypes.Int8, `[-1, null, 2]`, `["-1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Uint8, `[1, null, 2]`, `["1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Int16, `[-1, null, 2]`, `["-1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Uint16, `[1, null, 2]`, `["1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Int32, `[-1, null, 2]`, `["-1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Uint32, `[1, null, 2]`, `["1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Int64, `[-1, null, 2]`, `["-1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Uint64, `[1, null, 2]`, `["1", null,
"2"]`},
+ {arrow.PrimitiveTypes.Float32, `[1.5, null, 2]`, `["1.5", null,
"2"]`},
+ {arrow.PrimitiveTypes.Float64, `[1.5, null, 2]`, `["1.5", null,
"2"]`},
+ {arrow.FixedWidthTypes.Date32, `[0, null, 1]`, `["1970-01-01",
null, "1970-01-02"]`},
+ {arrow.FixedWidthTypes.Date64, `[0, null, 86400000]`,
`["1970-01-01", null, "1970-01-02"]`},
+ {arrow.FixedWidthTypes.Time32s, `[1, null, 62]`, `["00:00:01",
null, "00:01:02"]`},
+ {arrow.FixedWidthTypes.Time64ns, `[0, null, 1]`,
`["00:00:00.000000000", null, "00:00:00.000000001"]`},
+ {&arrow.TimestampType{Unit: arrow.Second}, `[0, null, 1]`,
`["1970-01-01 00:00:00", null, "1970-01-01 00:00:01"]`},
+ {arrow.FixedWidthTypes.Timestamp_s, `[0, null, 1]`,
`["1970-01-01 00:00:00Z", null, "1970-01-01 00:00:01Z"]`},
Review Comment:
nit: `time32[ms]`, `time64[us]` and timestamp `ms`/`us`/`ns` aren't covered.
They use the same generic kernels, so this is low-risk; adding them is optional.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]