forked from parquet-go/parquet-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_test.go
67 lines (55 loc) · 1.23 KB
/
filter_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package parquet_test
import (
"testing"
"github.com/parquet-go/parquet-go"
)
func TestFilterRowReader(t *testing.T) {
rows := []parquet.Row{
{parquet.Int64Value(0)},
{parquet.Int64Value(1)},
{parquet.Int64Value(2)},
{parquet.Int64Value(3)},
{parquet.Int64Value(4)},
}
want := []parquet.Row{
{parquet.Int64Value(0)},
{parquet.Int64Value(2)},
{parquet.Int64Value(4)},
}
reader := parquet.FilterRowReader(&bufferedRows{rows: rows},
func(row parquet.Row) bool {
return row[0].Int64()%2 == 0
},
)
writer := &bufferedRows{}
_, err := parquet.CopyRows(writer, reader)
if err != nil {
t.Fatal(err)
}
assertEqualRows(t, want, writer.rows)
}
func TestFilterRowWriter(t *testing.T) {
rows := []parquet.Row{
{parquet.Int64Value(0)},
{parquet.Int64Value(1)},
{parquet.Int64Value(2)},
{parquet.Int64Value(3)},
{parquet.Int64Value(4)},
}
want := []parquet.Row{
{parquet.Int64Value(1)},
{parquet.Int64Value(3)},
}
buffer := &bufferedRows{}
writer := parquet.FilterRowWriter(buffer,
func(row parquet.Row) bool {
return row[0].Int64()%2 == 1
},
)
reader := &bufferedRows{rows: rows}
_, err := parquet.CopyRows(writer, reader)
if err != nil {
t.Fatal(err)
}
assertEqualRows(t, want, buffer.rows)
}