Skip to content

Commit

Permalink
unit test (#785)
Browse files Browse the repository at this point in the history
* unit test

Ensures optional and required uint64 conversions work as expected
  • Loading branch information
thorfour authored Mar 26, 2024
1 parent 33934e0 commit 1bee562
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pqarrow/parquet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,40 @@ func BenchmarkRecordDynamicCols(b *testing.B) {
_ = RecordDynamicCols(r)
}
}

func Test_Uint64RecordToRow(t *testing.T) {
alloc := memory.NewCheckedAllocator(memory.NewGoAllocator())
defer alloc.AssertSize(t, 0)
build := array.NewRecordBuilder(alloc,
arrow.NewSchema([]arrow.Field{
{
Name: "value",
Type: arrow.PrimitiveTypes.Uint64,
},
}, nil),
)
defer build.Release()
build.Field(0).(*array.Uint64Builder).AppendValues([]uint64{0, 1, 2, 3}, nil)
r := build.NewRecord()
defer r.Release()

// Build with required
parquetFields := parquet.Group{}
parquetFields["value"] = parquet.Required(parquet.Int(64))
schema := parquet.NewSchema("test", parquetFields)

row, err := RecordToRow(schema, r, 2)
require.NoError(t, err)

require.Equal(t, "[2]", fmt.Sprintf("%v", row))

// Build with optional
parquetFields = parquet.Group{}
parquetFields["value"] = parquet.Optional(parquet.Int(64))
schema = parquet.NewSchema("test", parquetFields)

row, err = RecordToRow(schema, r, 2)
require.NoError(t, err)

require.Equal(t, "[2]", fmt.Sprintf("%v", row))
}

0 comments on commit 1bee562

Please sign in to comment.