Skip to content

Commit

Permalink
fix issue 362 (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
Achille authored Oct 5, 2022
1 parent 2b6feda commit 771b3e3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
59 changes: 55 additions & 4 deletions parquet_go18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package parquet_test
import (
"bytes"
"fmt"
"io"
"log"
"os"
"reflect"
"testing"

Expand Down Expand Up @@ -156,11 +158,60 @@ func TestIssue360(t *testing.T) {
},
}

if !reflect.DeepEqual(rows, expect) {
assertRowsEqual(t, expect, rows)
}

func TestIssue362ParquetReadFromGenericReaders(t *testing.T) {
path := "testdata/dms_test_table_LOAD00000001.parquet"
fp, err := os.Open(path)
if err != nil {
t.Fatal(err)
}
defer fp.Close()

r1 := parquet.NewGenericReader[any](fp)
rows1 := make([]any, r1.NumRows())
_, err = r1.Read(rows1)
if err != nil && err != io.EOF {
t.Fatal(err)
}

r2 := parquet.NewGenericReader[any](fp)
rows2 := make([]any, r2.NumRows())
_, err = r2.Read(rows2)
if err != nil && err != io.EOF {
t.Fatal(err)
}
}

func TestIssue362ParquetReadFile(t *testing.T) {
rows1, err := parquet.ReadFile[any]("testdata/dms_test_table_LOAD00000001.parquet")
if err != nil {
t.Fatal(err)
}

rows2, err := parquet.ReadFile[any]("testdata/dms_test_table_LOAD00000001.parquet")
if err != nil {
t.Fatal(err)
}

assertRowsEqual(t, rows1, rows2)
}

func assertRowsEqual(t *testing.T, rows1, rows2 []any) {
if !reflect.DeepEqual(rows1, rows2) {
t.Error("rows mismatch")

for _, row := range rows {
t.Logf("%#v", row)
}
t.Log("want:")
logRows(t, rows1)

t.Log("got:")
logRows(t, rows2)
}
}

func logRows(t *testing.T, rows []any) {
for _, row := range rows {
t.Logf(". %#v\n", row)
}
}
Binary file added testdata/dms_test_table_LOAD00000001.parquet
Binary file not shown.
2 changes: 1 addition & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func assignValue(dst reflect.Value, src Value) error {
return nil
}
default:
val = reflect.ValueOf(v)
val = reflect.ValueOf(copyBytes(v))
}
}

Expand Down

0 comments on commit 771b3e3

Please sign in to comment.