hermanschaaf commented on code in PR #34719: URL: https://github.com/apache/arrow/pull/34719#discussion_r1147556685
########## go/arrow/compute/vector_sort_indices_test.go: ########## @@ -0,0 +1,111 @@ +package compute_test + +import ( + "context" + "strings" + "testing" + + "github.com/apache/arrow/go/v12/arrow" + "github.com/apache/arrow/go/v12/arrow/array" + "github.com/apache/arrow/go/v12/arrow/compute" + "github.com/apache/arrow/go/v12/arrow/memory" + "github.com/stretchr/testify/suite" +) + +type SortIndicesSuite struct { + suite.Suite + mem *memory.CheckedAllocator + + valueType arrow.DataType + jsonData []string + expectIndices []int64 + + expected compute.Datum + input compute.Datum + + ctx context.Context +} + +func (suite *SortIndicesSuite) SetupTest() { + suite.mem = memory.NewCheckedAllocator(memory.DefaultAllocator) + suite.ctx = compute.WithAllocator(context.Background(), suite.mem) + + var err error + inputChunks := make([]arrow.Array, len(suite.jsonData)) + for i, data := range suite.jsonData { + inputChunks[i], _, err = array.FromJSON(suite.mem, + suite.valueType, strings.NewReader(data)) + suite.Require().NoError(err) + } + + exp := array.NewInt64Builder(suite.mem) + exp.AppendValues(suite.expectIndices, nil) + arr := exp.NewArray().Data() + suite.expected = &compute.ArrayDatum{Value: arr} + chunked := arrow.NewChunked(inputChunks[0].DataType(), inputChunks) + suite.input = &compute.ChunkedDatum{Value: chunked} + + for i := range inputChunks { + inputChunks[i].Release() + } + exp.Release() +} + +func (suite *SortIndicesSuite) TearDownTest() { + suite.expected.Release() + suite.input.Release() + suite.mem.AssertSize(suite.T(), 0) +} + +func (suite *SortIndicesSuite) TestSortIndices() { + result, err := compute.SortIndices(suite.ctx, + compute.SortIndicesOptions{ + NullPlacement: 0, + }, suite.input) + suite.Require().NoError(err) + defer result.Release() + + assertDatumsEqual(suite.T(), suite.expected, result, nil, nil) +} + +func TestSortIndicesFunctions(t *testing.T) { + // base64 encoded for testing fixed size binary + const ( + valAba = `YWJh` + valAbc = `YWJj` + valAbd = `YWJk` + ) + + tests := []struct { + name string + data []string + expect []int64 + valueType arrow.DataType + }{ + {"simple int32", []string{`[1, 1, 0, -5, -5, -5, 255, 255]`}, []int64{3, 4, 5, 2, 0, 1, 6, 7}, arrow.PrimitiveTypes.Int32}, Review Comment: Just trying to get a single simple test case to pass for now -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org