@@ -128,117 +128,128 @@ class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContex
128128 }
129129
130130 test(" filter pushdown - boolean" ) {
131- withParquetDataFrame((true :: false :: Nil ).map(b => Tuple1 .apply(Option (b)))) { implicit df =>
132- checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
133- checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], Seq (Row (true ), Row (false )))
134-
135- checkFilterPredicate(' _1 === true , classOf [Eq [_]], true )
136- checkFilterPredicate(' _1 <=> true , classOf [Eq [_]], true )
137- checkFilterPredicate(' _1 !== true , classOf [NotEq [_]], false )
131+ withSQLConf(SQLConf .PARQUET_FILTER_PUSHDOWN_ENABLED .key -> " true" ) {
132+ withParquetDataFrame((true :: false :: Nil ).map(b => Tuple1 .apply(Option (b))))
133+ { implicit df =>
134+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
135+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], Seq (Row (true ), Row (false )))
136+
137+ checkFilterPredicate(' _1 === true , classOf [Eq [_]], true )
138+ checkFilterPredicate(' _1 <=> true , classOf [Eq [_]], true )
139+ checkFilterPredicate(' _1 !== true , classOf [NotEq [_]], false )
140+ }
138141 }
139142 }
140143
141144 test(" filter pushdown - integer" ) {
142- withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i)))) { implicit df =>
143- checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
144- checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
145-
146- checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
147- checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
148- checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
149-
150- checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
151- checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
152- checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
153- checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
154-
155- checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
156- checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
157- checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
158- checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
159- checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
160- checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
161-
162- checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
163- checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
145+ withSQLConf(SQLConf .PARQUET_FILTER_PUSHDOWN_ENABLED .key -> " true" ) {
146+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i)))) { implicit df =>
147+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
148+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
149+
150+ checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
151+ checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
152+ checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
153+
154+ checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
155+ checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
156+ checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
157+ checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
158+
159+ checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
160+ checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
161+ checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
162+ checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
163+ checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
164+ checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
165+
166+ checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
167+ checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
168+ }
164169 }
165170 }
166171
167172 test(" filter pushdown - long" ) {
168- withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toLong)))) { implicit df =>
169- checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
170- checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
171-
172- checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
173- checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
174- checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
175-
176- checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
177- checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
178- checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
179- checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
180-
181- checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
182- checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
183- checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
184- checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
185- checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
186- checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
187-
188- checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
189- checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
173+ withSQLConf(SQLConf .PARQUET_FILTER_PUSHDOWN_ENABLED .key -> " true" ) {
174+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toLong)))) { implicit df =>
175+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
176+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
177+
178+ checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
179+ checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
180+ checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
181+
182+ checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
183+ checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
184+ checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
185+ checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
186+
187+ checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
188+ checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
189+ checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
190+ checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
191+ checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
192+ checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
193+
194+ checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
195+ checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
196+ }
190197 }
191198 }
192199
193200 test(" filter pushdown - float" ) {
194- withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toFloat)))) { implicit df =>
195- checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
196- checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
197-
198- checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
199- checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
200- checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
201-
202- checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
203- checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
204- checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
205- checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
206-
207- checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
208- checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
209- checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
210- checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
211- checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
212- checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
213-
214- checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
215- checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
201+ withSQLConf(SQLConf .PARQUET_FILTER_PUSHDOWN_ENABLED .key -> " true" ) {
202+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toFloat)))) { implicit df =>
203+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
204+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
205+
206+ checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
207+ checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
208+ checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
209+
210+ checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
211+ checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
212+ checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
213+ checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
214+
215+ checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
216+ checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
217+ checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
218+ checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
219+ checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
220+ checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
221+
222+ checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
223+ checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
224+ }
216225 }
217226 }
218227
219228 test(" filter pushdown - double" ) {
220- withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toDouble)))) { implicit df =>
221- checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
222- checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
223-
224- checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
225- checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
226- checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
227-
228- checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
229- checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
230- checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
231- checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
232-
233- checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
234- checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
235- checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
236- checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
237- checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
238- checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
239-
240- checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
241- checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
229+ withSQLConf(SQLConf .PARQUET_FILTER_PUSHDOWN_ENABLED .key -> " true" ) {
230+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (Option (i.toDouble)))) { implicit df =>
231+ checkFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
232+ checkFilterPredicate(' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(Row .apply(_)))
233+
234+ checkFilterPredicate(' _1 === 1 , classOf [Eq [_]], 1 )
235+ checkFilterPredicate(' _1 <=> 1 , classOf [Eq [_]], 1 )
236+ checkFilterPredicate(' _1 !== 1 , classOf [NotEq [_]], (2 to 4 ).map(Row .apply(_)))
237+
238+ checkFilterPredicate(' _1 < 2 , classOf [Lt [_]], 1 )
239+ checkFilterPredicate(' _1 > 3 , classOf [Gt [_]], 4 )
240+ checkFilterPredicate(' _1 <= 1 , classOf [LtEq [_]], 1 )
241+ checkFilterPredicate(' _1 >= 4 , classOf [GtEq [_]], 4 )
242+
243+ checkFilterPredicate(Literal (1 ) === ' _1 , classOf [Eq [_]], 1 )
244+ checkFilterPredicate(Literal (1 ) <=> ' _1 , classOf [Eq [_]], 1 )
245+ checkFilterPredicate(Literal (2 ) > ' _1 , classOf [Lt [_]], 1 )
246+ checkFilterPredicate(Literal (3 ) < ' _1 , classOf [Gt [_]], 4 )
247+ checkFilterPredicate(Literal (1 ) >= ' _1 , classOf [LtEq [_]], 1 )
248+ checkFilterPredicate(Literal (4 ) <= ' _1 , classOf [GtEq [_]], 4 )
249+
250+ checkFilterPredicate(! (' _1 < 4 ), classOf [GtEq [_]], 4 )
251+ checkFilterPredicate(' _1 < 2 || ' _1 > 3 , classOf [Operators .Or ], Seq (Row (1 ), Row (4 )))
252+ }
242253 }
243254 }
244255
@@ -277,32 +288,34 @@ class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContex
277288 def b : Array [Byte ] = int.toString.getBytes(" UTF-8" )
278289 }
279290
280- withParquetDataFrame((1 to 4 ).map(i => Tuple1 (i.b))) { implicit df =>
281- checkBinaryFilterPredicate(' _1 === 1 .b, classOf [Eq [_]], 1 .b)
282- checkBinaryFilterPredicate(' _1 <=> 1 .b, classOf [Eq [_]], 1 .b)
283-
284- checkBinaryFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
285- checkBinaryFilterPredicate(
286- ' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(i => Row .apply(i.b)).toSeq)
287-
288- checkBinaryFilterPredicate(
289- ' _1 !== 1 .b, classOf [NotEq [_]], (2 to 4 ).map(i => Row .apply(i.b)).toSeq)
290-
291- checkBinaryFilterPredicate(' _1 < 2 .b, classOf [Lt [_]], 1 .b)
292- checkBinaryFilterPredicate(' _1 > 3 .b, classOf [Gt [_]], 4 .b)
293- checkBinaryFilterPredicate(' _1 <= 1 .b, classOf [LtEq [_]], 1 .b)
294- checkBinaryFilterPredicate(' _1 >= 4 .b, classOf [GtEq [_]], 4 .b)
295-
296- checkBinaryFilterPredicate(Literal (1 .b) === ' _1 , classOf [Eq [_]], 1 .b)
297- checkBinaryFilterPredicate(Literal (1 .b) <=> ' _1 , classOf [Eq [_]], 1 .b)
298- checkBinaryFilterPredicate(Literal (2 .b) > ' _1 , classOf [Lt [_]], 1 .b)
299- checkBinaryFilterPredicate(Literal (3 .b) < ' _1 , classOf [Gt [_]], 4 .b)
300- checkBinaryFilterPredicate(Literal (1 .b) >= ' _1 , classOf [LtEq [_]], 1 .b)
301- checkBinaryFilterPredicate(Literal (4 .b) <= ' _1 , classOf [GtEq [_]], 4 .b)
302-
303- checkBinaryFilterPredicate(! (' _1 < 4 .b), classOf [GtEq [_]], 4 .b)
304- checkBinaryFilterPredicate(
305- ' _1 < 2 .b || ' _1 > 3 .b, classOf [Operators .Or ], Seq (Row (1 .b), Row (4 .b)))
291+ withSQLConf(SQLConf .PARQUET_FILTER_PUSHDOWN_ENABLED .key -> " true" ) {
292+ withParquetDataFrame((1 to 4 ).map(i => Tuple1 (i.b))) { implicit df =>
293+ checkBinaryFilterPredicate(' _1 === 1 .b, classOf [Eq [_]], 1 .b)
294+ checkBinaryFilterPredicate(' _1 <=> 1 .b, classOf [Eq [_]], 1 .b)
295+
296+ checkBinaryFilterPredicate(' _1 .isNull, classOf [Eq [_]], Seq .empty[Row ])
297+ checkBinaryFilterPredicate(
298+ ' _1 .isNotNull, classOf [NotEq [_]], (1 to 4 ).map(i => Row .apply(i.b)).toSeq)
299+
300+ checkBinaryFilterPredicate(
301+ ' _1 !== 1 .b, classOf [NotEq [_]], (2 to 4 ).map(i => Row .apply(i.b)).toSeq)
302+
303+ checkBinaryFilterPredicate(' _1 < 2 .b, classOf [Lt [_]], 1 .b)
304+ checkBinaryFilterPredicate(' _1 > 3 .b, classOf [Gt [_]], 4 .b)
305+ checkBinaryFilterPredicate(' _1 <= 1 .b, classOf [LtEq [_]], 1 .b)
306+ checkBinaryFilterPredicate(' _1 >= 4 .b, classOf [GtEq [_]], 4 .b)
307+
308+ checkBinaryFilterPredicate(Literal (1 .b) === ' _1 , classOf [Eq [_]], 1 .b)
309+ checkBinaryFilterPredicate(Literal (1 .b) <=> ' _1 , classOf [Eq [_]], 1 .b)
310+ checkBinaryFilterPredicate(Literal (2 .b) > ' _1 , classOf [Lt [_]], 1 .b)
311+ checkBinaryFilterPredicate(Literal (3 .b) < ' _1 , classOf [Gt [_]], 4 .b)
312+ checkBinaryFilterPredicate(Literal (1 .b) >= ' _1 , classOf [LtEq [_]], 1 .b)
313+ checkBinaryFilterPredicate(Literal (4 .b) <= ' _1 , classOf [GtEq [_]], 4 .b)
314+
315+ checkBinaryFilterPredicate(! (' _1 < 4 .b), classOf [GtEq [_]], 4 .b)
316+ checkBinaryFilterPredicate(
317+ ' _1 < 2 .b || ' _1 > 3 .b, classOf [Operators .Or ], Seq (Row (1 .b), Row (4 .b)))
318+ }
306319 }
307320 }
308321
0 commit comments