forked from segmentio/parquet-go
/
schema_test.go
68 lines (60 loc) · 1.08 KB
/
schema_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
68
package parquet_test
import (
"testing"
"github.com/segmentio/parquet-go"
)
func TestSchemaOf(t *testing.T) {
tests := []struct {
value interface{}
print string
}{
{
value: new(struct{ Name string }),
print: `message {
required binary Name (STRING);
}`,
},
{
value: new(struct {
X int
Y int
}),
print: `message {
required int64 X (INT(64,true));
required int64 Y (INT(64,true));
}`,
},
{
value: new(struct {
X float32
Y float32
}),
print: `message {
required float X;
required float Y;
}`,
},
{
value: new(struct {
Inner struct {
FirstName string `parquet:"first_name"`
LastName string `parquet:"last_name"`
} `parquet:"inner,optional"`
}),
print: `message {
optional group inner {
required binary first_name (STRING);
required binary last_name (STRING);
}
}`,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
schema := parquet.SchemaOf(test.value)
if s := schema.String(); s != test.print {
t.Errorf("\nexpected:\n\n%s\n\nfound:\n\n%s\n", test.print, s)
}
})
}
}