@@ -178,6 +178,62 @@ class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContex
178178 }
179179 }
180180
181+ test(s " filter pushdown - ByteType " ) {
182+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toByte)))) { implicit df =>
183+ assert(df.schema.head.dataType === ByteType )
184+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
185+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
186+
187+ checkFilterPredicate(' _1 === 1 .toByte, classOf [Eq [_]], 1 )
188+ checkFilterPredicate(' _1 <=> 1 .toByte, classOf [Eq [_]], 1 )
189+ checkFilterPredicate(' _1 =!= 1 .toByte, classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
190+
191+ checkFilterPredicate(' _1 < 2 .toByte, classOf [Lt [_]], 1 )
192+ checkFilterPredicate(' _1 > 3 .toByte, classOf [Gt [_]], 4 )
193+ checkFilterPredicate(' _1 <= 1 .toByte, classOf [LtEq [_]], 1 )
194+ checkFilterPredicate(' _1 >= 4 .toByte, classOf [GtEq [_]], 4 )
195+
196+ checkFilterPredicate(Literal (1 .toByte) === ' _1 , classOf [Eq [_]], 1 )
197+ checkFilterPredicate(Literal (1 .toByte) <=> ' _1 , classOf [Eq [_]], 1 )
198+ checkFilterPredicate(Literal (2 .toByte) > ' _1 , classOf [Lt [_]], 1 )
199+ checkFilterPredicate(Literal (3 .toByte) < ' _1 , classOf [Gt [_]], 4 )
200+ checkFilterPredicate(Literal (1 .toByte) >= ' _1 , classOf [LtEq [_]], 1 )
201+ checkFilterPredicate(Literal (4 .toByte) <= ' _1 , classOf [GtEq [_]], 4 )
202+
203+ checkFilterPredicate(! (' _1 < 4 .toByte), classOf [GtEq [_]], 4 )
204+ checkFilterPredicate(' _1 < 2 .toByte || ' _1 > 3 .toByte,
205+ classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
206+ }
207+ }
208+
209+ test(s " filter pushdown - ShortType " ) {
210+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toShort)))) { implicit df =>
211+ assert(df.schema.head.dataType === ShortType )
212+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
213+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
214+
215+ checkFilterPredicate(' _1 === 1 .toShort, classOf [Eq [_]], 1 )
216+ checkFilterPredicate(' _1 <=> 1 .toShort, classOf [Eq [_]], 1 )
217+ checkFilterPredicate(' _1 =!= 1 .toShort, classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
218+
219+ checkFilterPredicate(' _1 < 2 .toShort, classOf [Lt [_]], 1 )
220+ checkFilterPredicate(' _1 > 3 .toShort, classOf [Gt [_]], 4 )
221+ checkFilterPredicate(' _1 <= 1 .toShort, classOf [LtEq [_]], 1 )
222+ checkFilterPredicate(' _1 >= 4 .toShort, classOf [GtEq [_]], 4 )
223+
224+ checkFilterPredicate(Literal (1 .toShort) === ' _1 , classOf [Eq [_]], 1 )
225+ checkFilterPredicate(Literal (1 .toShort) <=> ' _1 , classOf [Eq [_]], 1 )
226+ checkFilterPredicate(Literal (2 .toShort) > ' _1 , classOf [Lt [_]], 1 )
227+ checkFilterPredicate(Literal (3 .toShort) < ' _1 , classOf [Gt [_]], 4 )
228+ checkFilterPredicate(Literal (1 .toShort) >= ' _1 , classOf [LtEq [_]], 1 )
229+ checkFilterPredicate(Literal (4 .toShort) <= ' _1 , classOf [GtEq [_]], 4 )
230+
231+ checkFilterPredicate(! (' _1 < 4 .toShort), classOf [GtEq [_]], 4 )
232+ checkFilterPredicate(' _1 < 2 .toShort || ' _1 > 3 .toShort,
233+ classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
234+ }
235+ }
236+
181237 test(" filter pushdown - integer" ) {
182238 withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i)))) { implicit df =>
183239 checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
0 commit comments