|
36 | 36 | import static org.apache.parquet.schema.OriginalType.UTF8; |
37 | 37 | import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.BINARY; |
38 | 38 | import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT64; |
39 | | -import static org.junit.Assert.assertEquals; |
| 39 | +import static org.assertj.core.api.Assertions.assertThat; |
40 | 40 |
|
41 | 41 | import java.io.File; |
42 | 42 | import java.io.IOException; |
@@ -99,116 +99,110 @@ public void createDataFile() throws Exception { |
99 | 99 |
|
100 | 100 | @Test |
101 | 101 | public void testNormalFilter() throws Exception { |
102 | | - assertEquals(500, countFilteredRecords(path, lt(longColumn("id"), 500L))); |
| 102 | + assertThat(countFilteredRecords(path, lt(longColumn("id"), 500L))).isEqualTo(500); |
103 | 103 | } |
104 | 104 |
|
105 | 105 | @Test |
106 | 106 | public void testSimpleMissingColumnFilter() throws Exception { |
107 | | - assertEquals(0, countFilteredRecords(path, lt(longColumn("missing"), 500L))); |
| 107 | + assertThat(countFilteredRecords(path, lt(longColumn("missing"), 500L))).isEqualTo(0); |
108 | 108 | Set<Long> values = new HashSet<>(); |
109 | 109 | values.add(1L); |
110 | 110 | values.add(2L); |
111 | 111 | values.add(5L); |
112 | | - assertEquals(0, countFilteredRecords(path, in(longColumn("missing"), values))); |
113 | | - assertEquals(1000, countFilteredRecords(path, notIn(longColumn("missing"), values))); |
| 112 | + assertThat(countFilteredRecords(path, in(longColumn("missing"), values))) |
| 113 | + .isEqualTo(0); |
| 114 | + assertThat(countFilteredRecords(path, notIn(longColumn("missing"), values))) |
| 115 | + .isEqualTo(1000); |
114 | 116 | } |
115 | 117 |
|
116 | 118 | @Test |
117 | 119 | public void testAndMissingColumnFilter() throws Exception { |
118 | 120 | // missing column filter is true |
119 | | - assertEquals( |
120 | | - 500, countFilteredRecords(path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null)))); |
121 | | - assertEquals( |
122 | | - 500, |
123 | | - countFilteredRecords( |
124 | | - path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any"))))); |
125 | | - |
126 | | - assertEquals( |
127 | | - 500, countFilteredRecords(path, and(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))); |
128 | | - assertEquals( |
129 | | - 500, |
130 | | - countFilteredRecords( |
131 | | - path, and(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))); |
| 121 | + assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null)))) |
| 122 | + .isEqualTo(500); |
| 123 | + assertThat(countFilteredRecords( |
| 124 | + path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any"))))) |
| 125 | + .isEqualTo(500); |
| 126 | + |
| 127 | + assertThat(countFilteredRecords(path, and(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))) |
| 128 | + .isEqualTo(500); |
| 129 | + assertThat(countFilteredRecords( |
| 130 | + path, and(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))) |
| 131 | + .isEqualTo(500); |
132 | 132 |
|
133 | 133 | // missing column filter is false |
134 | | - assertEquals( |
135 | | - 0, |
136 | | - countFilteredRecords( |
137 | | - path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any"))))); |
138 | | - assertEquals( |
139 | | - 0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null)))); |
140 | | - assertEquals( |
141 | | - 0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33)))); |
142 | | - assertEquals( |
143 | | - 0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33)))); |
144 | | - assertEquals( |
145 | | - 0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33)))); |
146 | | - assertEquals( |
147 | | - 0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33)))); |
148 | | - |
149 | | - assertEquals( |
150 | | - 0, |
151 | | - countFilteredRecords( |
152 | | - path, and(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))); |
153 | | - assertEquals( |
154 | | - 0, countFilteredRecords(path, and(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))); |
155 | | - assertEquals( |
156 | | - 0, countFilteredRecords(path, and(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
157 | | - assertEquals( |
158 | | - 0, countFilteredRecords(path, and(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
159 | | - assertEquals( |
160 | | - 0, countFilteredRecords(path, and(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
161 | | - assertEquals( |
162 | | - 0, countFilteredRecords(path, and(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
| 134 | + assertThat(countFilteredRecords( |
| 135 | + path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any"))))) |
| 136 | + .isEqualTo(0); |
| 137 | + assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null)))) |
| 138 | + .isEqualTo(0); |
| 139 | + assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33)))) |
| 140 | + .isEqualTo(0); |
| 141 | + assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33)))) |
| 142 | + .isEqualTo(0); |
| 143 | + assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33)))) |
| 144 | + .isEqualTo(0); |
| 145 | + assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33)))) |
| 146 | + .isEqualTo(0); |
| 147 | + |
| 148 | + assertThat(countFilteredRecords( |
| 149 | + path, and(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))) |
| 150 | + .isEqualTo(0); |
| 151 | + assertThat(countFilteredRecords(path, and(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))) |
| 152 | + .isEqualTo(0); |
| 153 | + assertThat(countFilteredRecords(path, and(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 154 | + .isEqualTo(0); |
| 155 | + assertThat(countFilteredRecords(path, and(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 156 | + .isEqualTo(0); |
| 157 | + assertThat(countFilteredRecords(path, and(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 158 | + .isEqualTo(0); |
| 159 | + assertThat(countFilteredRecords(path, and(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 160 | + .isEqualTo(0); |
163 | 161 | } |
164 | 162 |
|
165 | 163 | @Test |
166 | 164 | public void testOrMissingColumnFilter() throws Exception { |
167 | 165 | // missing column filter is false |
168 | | - assertEquals( |
169 | | - 500, |
170 | | - countFilteredRecords( |
171 | | - path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any"))))); |
172 | | - assertEquals( |
173 | | - 500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null)))); |
174 | | - assertEquals( |
175 | | - 500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33)))); |
176 | | - assertEquals( |
177 | | - 500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33)))); |
178 | | - assertEquals( |
179 | | - 500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33)))); |
180 | | - assertEquals( |
181 | | - 500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33)))); |
182 | | - |
183 | | - assertEquals( |
184 | | - 500, |
185 | | - countFilteredRecords( |
186 | | - path, or(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))); |
187 | | - assertEquals( |
188 | | - 500, countFilteredRecords(path, or(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))); |
189 | | - assertEquals( |
190 | | - 500, countFilteredRecords(path, or(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
191 | | - assertEquals( |
192 | | - 500, countFilteredRecords(path, or(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
193 | | - assertEquals( |
194 | | - 500, countFilteredRecords(path, or(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
195 | | - assertEquals( |
196 | | - 500, countFilteredRecords(path, or(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))); |
| 166 | + assertThat(countFilteredRecords( |
| 167 | + path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any"))))) |
| 168 | + .isEqualTo(500); |
| 169 | + assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null)))) |
| 170 | + .isEqualTo(500); |
| 171 | + assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33)))) |
| 172 | + .isEqualTo(500); |
| 173 | + assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33)))) |
| 174 | + .isEqualTo(500); |
| 175 | + assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33)))) |
| 176 | + .isEqualTo(500); |
| 177 | + assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33)))) |
| 178 | + .isEqualTo(500); |
| 179 | + |
| 180 | + assertThat(countFilteredRecords( |
| 181 | + path, or(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))) |
| 182 | + .isEqualTo(500); |
| 183 | + assertThat(countFilteredRecords(path, or(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))) |
| 184 | + .isEqualTo(500); |
| 185 | + assertThat(countFilteredRecords(path, or(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 186 | + .isEqualTo(500); |
| 187 | + assertThat(countFilteredRecords(path, or(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 188 | + .isEqualTo(500); |
| 189 | + assertThat(countFilteredRecords(path, or(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 190 | + .isEqualTo(500); |
| 191 | + assertThat(countFilteredRecords(path, or(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L)))) |
| 192 | + .isEqualTo(500); |
197 | 193 |
|
198 | 194 | // missing column filter is false |
199 | | - assertEquals( |
200 | | - 1000, countFilteredRecords(path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null)))); |
201 | | - assertEquals( |
202 | | - 1000, |
203 | | - countFilteredRecords( |
204 | | - path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any"))))); |
205 | | - |
206 | | - assertEquals( |
207 | | - 1000, countFilteredRecords(path, or(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))); |
208 | | - assertEquals( |
209 | | - 1000, |
210 | | - countFilteredRecords( |
211 | | - path, or(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))); |
| 195 | + assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null)))) |
| 196 | + .isEqualTo(1000); |
| 197 | + assertThat(countFilteredRecords( |
| 198 | + path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any"))))) |
| 199 | + .isEqualTo(1000); |
| 200 | + |
| 201 | + assertThat(countFilteredRecords(path, or(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L)))) |
| 202 | + .isEqualTo(1000); |
| 203 | + assertThat(countFilteredRecords( |
| 204 | + path, or(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L)))) |
| 205 | + .isEqualTo(1000); |
212 | 206 | } |
213 | 207 |
|
214 | 208 | public static long countFilteredRecords(Path path, FilterPredicate pred) throws IOException { |
|
0 commit comments