From bcdc4570dd49ca4e1f2da368ee338a7b6ed9a2f4 Mon Sep 17 00:00:00 2001 From: Benjamin Prosnitz Date: Tue, 15 Nov 2022 13:01:44 -0500 Subject: [PATCH] Fix panic when reading file with no row groups (#408) --- file.go | 4 ++++ testdata/empty.parquet | Bin 0 -> 90 bytes 2 files changed, 4 insertions(+) create mode 100644 testdata/empty.parquet diff --git a/file.go b/file.go index 164c517..0dcbb1a 100644 --- a/file.go +++ b/file.go @@ -174,6 +174,10 @@ func OpenFile(r io.ReaderAt, size int64, options ...FileOption) (*File, error) { // this case the page index is not cached within the file, programs are expected // to make use of independently from the parquet package. func (f *File) ReadPageIndex() ([]format.ColumnIndex, []format.OffsetIndex, error) { + if len(f.metadata.RowGroups) == 0 { + return nil, nil, nil + } + columnIndexOffset := f.metadata.RowGroups[0].Columns[0].ColumnIndexOffset offsetIndexOffset := f.metadata.RowGroups[0].Columns[0].OffsetIndexOffset columnIndexLength := int64(0) diff --git a/testdata/empty.parquet b/testdata/empty.parquet new file mode 100644 index 0000000000000000000000000000000000000000..e36cbef74c5d4f5543f95bee1e4d2f8b223503db GIT binary patch literal 90 zcmWG=3^EjDlGHI}kl-&!EGjHbEs0Ohk1xv4FA-&85M>f&5M_{HElbQPO*I8FMHv{x m7$kW#B%x|`)AJR|Qj3Z+^YavP5=&BxOBnnZ7#IS8rUC%s{T9vu literal 0 HcmV?d00001