Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
don4get committed Aug 26, 2024
1 parent 9f0d317 commit 72b71f7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions ci/scripts/go_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ go test $testargs -tags $TAGS,noasm ./...
popd

export PARQUET_TEST_DATA=${1}/cpp/submodules/parquet-testing/data
export PARQUET_TEST_BAD_DATA=${1}/cpp/submodules/parquet-testing/bad_data
export ARROW_TEST_DATA=${1}/testing/data
pushd ${source_dir}/parquet

Expand Down
41 changes: 41 additions & 0 deletions go/parquet/pqarrow/file_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -373,3 +374,43 @@ func TestFileReaderColumnChunkBoundsErrors(t *testing.T) {
assert.ErrorContains(t, tooHighErr, fmt.Sprintf("there are only %d columns", schema.NumFields()))
}
}

func TestReadParquetFile(t *testing.T) {
dir := os.Getenv("PARQUET_TEST_BAD_DATA")
if dir == "" {
t.Skip("no path supplied with PARQUET_TEST_BAD_DATA")
}
assert.DirExists(t, dir)
filename := path.Join(dir, "GH_43605.parquet")
ctx := context.TODO()

mem := memory.NewCheckedAllocator(memory.DefaultAllocator)

rdr, err := file.OpenParquetFile(
filename,
false,
file.WithReadProps(parquet.NewReaderProperties(mem)),
)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
defer func() {
if err2 := rdr.Close(); err2 != nil {
t.Errorf("unexpected error: %v", err2)
}
}()

arrowRdr, err := pqarrow.NewFileReader(rdr, pqarrow.ArrowReadProperties{
Parallel: false,
BatchSize: 0,
}, mem)
if err != nil {
t.Errorf("unexpected error: %v", err)
}

_, err = arrowRdr.ReadTable(ctx)

if err == nil {
t.Errorf("expected error: %v", err)
}
}

0 comments on commit 72b71f7

Please sign in to comment.