15
15
*/
16
16
package io .streamthoughts .kafka .connect .filepulse .fs .reader .parquet ;
17
17
18
+ import static org .apache .parquet .schema .PrimitiveType .PrimitiveTypeName .BINARY ;
19
+ import static org .apache .parquet .schema .PrimitiveType .PrimitiveTypeName .BOOLEAN ;
20
+ import static org .apache .parquet .schema .PrimitiveType .PrimitiveTypeName .DOUBLE ;
21
+ import static org .apache .parquet .schema .PrimitiveType .PrimitiveTypeName .FLOAT ;
22
+ import static org .apache .parquet .schema .PrimitiveType .PrimitiveTypeName .INT32 ;
23
+ import static org .apache .parquet .schema .PrimitiveType .PrimitiveTypeName .INT64 ;
24
+ import static org .apache .parquet .schema .Type .Repetition .REPEATED ;
25
+
18
26
import java .util .ArrayList ;
19
27
import java .util .List ;
20
-
21
28
import org .apache .parquet .example .data .simple .SimpleGroup ;
22
29
import org .apache .parquet .schema .*;
23
30
import org .junit .Assert ;
@@ -37,19 +44,19 @@ public class ParquetTypedStructConverterTest {
37
44
38
45
@ Test
39
46
public void check_string_value_converter () {
40
- var stringValue = new PrimitiveType (Type . Repetition . REPEATED , PrimitiveType . PrimitiveTypeName . BINARY , "test" );
47
+ var stringValue = new PrimitiveType (REPEATED , BINARY , "test" );
41
48
listType .add (stringValue );
42
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
49
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
43
50
simpleGroup .add (0 , STRING_VALUE );
44
51
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
45
52
46
53
Assert .assertEquals (STRING_VALUE , typedStruct .get ("test" ).getString ());
47
54
}
48
55
@ Test
49
56
public void check_int_value_converter () {
50
- var integerValue = new PrimitiveType (Type . Repetition . REPEATED , PrimitiveType . PrimitiveTypeName . INT32 , "integer" );
57
+ var integerValue = new PrimitiveType (REPEATED , INT32 , "integer" );
51
58
listType .add (0 , integerValue );
52
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
59
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
53
60
simpleGroup .add (0 , INT_VALUE );
54
61
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
55
62
@@ -58,9 +65,9 @@ public void check_int_value_converter() {
58
65
59
66
@ Test
60
67
public void check_double_value_converter () {
61
- var doubleValue = new PrimitiveType (Type . Repetition . REPEATED , PrimitiveType . PrimitiveTypeName . DOUBLE , "double" );
68
+ var doubleValue = new PrimitiveType (REPEATED , DOUBLE , "double" );
62
69
listType .add (0 , doubleValue );
63
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
70
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
64
71
simpleGroup .add (0 , DOUBLE_VALUE );
65
72
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
66
73
@@ -69,9 +76,9 @@ public void check_double_value_converter() {
69
76
70
77
@ Test
71
78
public void check_long_value_converter () {
72
- var longValue = new PrimitiveType (Type . Repetition . REPEATED , PrimitiveType . PrimitiveTypeName . INT64 , "long" );
79
+ var longValue = new PrimitiveType (REPEATED , INT64 , "long" );
73
80
listType .add (0 , longValue );
74
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
81
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
75
82
simpleGroup .add (0 , LONG_VALUE );
76
83
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
77
84
@@ -80,9 +87,9 @@ public void check_long_value_converter() {
80
87
81
88
@ Test
82
89
public void check_boolean_value_converter () {
83
- var booleanValue = new PrimitiveType (Type . Repetition . REPEATED , PrimitiveType . PrimitiveTypeName . BOOLEAN , "boolean" );
90
+ var booleanValue = new PrimitiveType (REPEATED , BOOLEAN , "boolean" );
84
91
listType .add (0 , booleanValue );
85
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
92
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
86
93
simpleGroup .add (0 , BOOLEAN_VALUE );
87
94
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
88
95
@@ -91,9 +98,9 @@ public void check_boolean_value_converter() {
91
98
92
99
@ Test
93
100
public void check_float_value_converter () {
94
- var floatValue = new PrimitiveType (Type . Repetition . REPEATED , PrimitiveType . PrimitiveTypeName . FLOAT , "float" );
101
+ var floatValue = new PrimitiveType (REPEATED , FLOAT , "float" );
95
102
listType .add (0 , floatValue );
96
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
103
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
97
104
simpleGroup .add (0 , FLOAT_VALUE );
98
105
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
99
106
@@ -103,7 +110,7 @@ public void check_float_value_converter() {
103
110
@ Test
104
111
public void check_array_value_converter () {
105
112
listType .add (0 , generateArray ());
106
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
113
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
107
114
simpleGroup .add (0 , baseArraySimpleGroup );
108
115
109
116
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
@@ -114,7 +121,7 @@ public void check_array_value_converter() {
114
121
@ Test
115
122
public void check_array_value_converter_when_array_is_empty () {
116
123
listType .add (0 , generateEmptyArray ());
117
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
124
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
118
125
simpleGroup .add (0 , baseArraySimpleGroup );
119
126
120
127
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
@@ -125,15 +132,15 @@ public void check_array_value_converter_when_array_is_empty() {
125
132
@ Test
126
133
public void check_value_converter_when_repetition_count_equals_0 () {
127
134
listType .add (0 , generateFieldRepetitionCountEmpty ());
128
- simpleGroup = new SimpleGroup (new GroupType (Type . Repetition . REPEATED , "name" , listType ));
135
+ simpleGroup = new SimpleGroup (new GroupType (REPEATED , "name" , listType ));
129
136
130
137
var typedStruct = ParquetTypedStructConverter .fromParquetFileReader (simpleGroup );
131
138
132
139
Assert .assertTrue (typedStruct .get ("REPLICATION_EMPTY" ).isNull ());
133
140
}
134
141
135
142
private GroupType generateArray () {
136
- var elementList = new PrimitiveType (Type .Repetition .OPTIONAL , PrimitiveType . PrimitiveTypeName . INT32 , "element" );
143
+ var elementList = new PrimitiveType (Type .Repetition .OPTIONAL , INT32 , "element" );
137
144
138
145
var dataList = new GroupType (Type .Repetition .OPTIONAL , "LIST" , elementList );
139
146
@@ -147,20 +154,20 @@ private GroupType generateArray() {
147
154
baseArraySimpleGroup = new SimpleGroup (schemaGroup );
148
155
baseArraySimpleGroup .add (0 , dataGroup1 );
149
156
baseArraySimpleGroup .add (0 , dataGroup2 );
150
- return ConversionPatterns .listOfElements (Type . Repetition . REPEATED , "LIST" , schemaGroup );
157
+ return ConversionPatterns .listOfElements (REPEATED , "LIST" , schemaGroup );
151
158
}
152
159
153
160
private GroupType generateEmptyArray () {
154
- var elementList = new PrimitiveType (Type .Repetition .OPTIONAL , PrimitiveType . PrimitiveTypeName . INT32 , "element" );
161
+ var elementList = new PrimitiveType (Type .Repetition .OPTIONAL , INT32 , "element" );
155
162
var dataList = new GroupType (Type .Repetition .OPTIONAL , "LIST" , elementList );
156
163
157
164
var schemaGroup = new GroupType (Type .Repetition .OPTIONAL , "element" , List .of (dataList ));
158
165
baseArraySimpleGroup = new SimpleGroup (schemaGroup );
159
- return ConversionPatterns .listOfElements (Type . Repetition . REPEATED , "EMPTY_LIST" , schemaGroup );
166
+ return ConversionPatterns .listOfElements (REPEATED , "EMPTY_LIST" , schemaGroup );
160
167
}
161
168
162
169
private GroupType generateFieldRepetitionCountEmpty () {
163
170
var schemaGroup = new GroupType (Type .Repetition .OPTIONAL , "element" );
164
- return ConversionPatterns .listOfElements (Type . Repetition . REPEATED , "REPLICATION_EMPTY" , schemaGroup );
171
+ return ConversionPatterns .listOfElements (REPEATED , "REPLICATION_EMPTY" , schemaGroup );
165
172
}
166
173
}
0 commit comments