Skip to content

Commit

Permalink
fix issue 343 (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Achille authored Sep 14, 2022
1 parent d2b49bc commit 67dbe8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion buffer_go18.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewGenericBuffer[T any](options ...RowGroupOption) *GenericBuffer[T] {
}

t := typeOf[T]()
if config.Schema == nil {
if config.Schema == nil && t != nil {
config.Schema = schemaOf(dereference(t))
}

Expand All @@ -53,6 +53,9 @@ func typeOf[T any]() reflect.Type {
type bufferFunc[T any] func(*GenericBuffer[T], []T) (int, error)

func bufferFuncOf[T any](t reflect.Type, schema *Schema) bufferFunc[T] {
if t == nil {
return (*GenericBuffer[T]).writeRows
}
switch t.Kind() {
case reflect.Interface, reflect.Map:
return (*GenericBuffer[T]).writeRows
Expand Down
5 changes: 5 additions & 0 deletions buffer_go18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,8 @@ func TestIssue327(t *testing.T) {
_ = parquet.NewGenericBuffer[testType]()
})
}

func TestIssue343(t *testing.T) {
// must not panic
_ = parquet.NewGenericBuffer[any]()
}

0 comments on commit 67dbe8d

Please sign in to comment.