From 67dbe8d21ca5679da0f69ca192fd7fce40c92186 Mon Sep 17 00:00:00 2001 From: Achille Date: Wed, 14 Sep 2022 15:24:23 -0700 Subject: [PATCH] fix issue 343 (#344) --- buffer_go18.go | 5 ++++- buffer_go18_test.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/buffer_go18.go b/buffer_go18.go index e393928..c073abf 100644 --- a/buffer_go18.go +++ b/buffer_go18.go @@ -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)) } @@ -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 diff --git a/buffer_go18_test.go b/buffer_go18_test.go index 51e08bf..9a9548a 100644 --- a/buffer_go18_test.go +++ b/buffer_go18_test.go @@ -181,3 +181,8 @@ func TestIssue327(t *testing.T) { _ = parquet.NewGenericBuffer[testType]() }) } + +func TestIssue343(t *testing.T) { + // must not panic + _ = parquet.NewGenericBuffer[any]() +}