xitongsys / parquet-go

pure golang library for reading/writing parquet file
Apache License 2.0
1.27k stars 293 forks source link

panic: when struct all field haive tag `omitstats=true` #526

Open diaket13 opened 1 year ago

diaket13 commented 1 year ago

version: v1.6.2 if use struct to generate SchemaHandler,Parquet_go_rootcan not set info because it can not set tag

like this struct

type Data struct {
    Value      string `parquet:"name=data, type=BYTE_ARRAY,convertedtype=UTF8, encoding=PLAIN_DICTIONARY, omitstats=true"`
    Timestamp int64  `parquet:"name=timestamp, type=INT64, omitstats=true"`
}

I set all fieldsomitstats=true,but the SchemaHandler's first item is the struct and it's omitstats is false. that will panic when call Flush(),because nullCount is nil

The following is panic information

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x148f2a9]

goroutine 48 [running]:
github.com/xitongsys/parquet-go/layout.PagesToDictChunk({0xc00006e580, 0x2, 0x2})
      /Users/wwx/go/src/go_pk_sensor/vendor/github.com/xitongsys/parquet-go/layout/chunk.go:108 +0x3e9
github.com/xitongsys/parquet-go/writer.(*ParquetWriter).Flush(0xc0000ba270, 0x1)
      /Users/wwx/go/src/go_pk_sensor/vendor/github.com/xitongsys/parquet-go/writer/writer.go:356 +0x2fd
github.com/xitongsys/parquet-go/writer.(*P(0xc0000ba270)
      /Users/wwx/go/src/go_pk_sensor/vendor/github.com/xitongsys/parquet-go/writer/writer.go:132 +0x38