@@ -40,10 +40,8 @@ use vortex::error::vortex_bail;
4040use vortex:: error:: vortex_err;
4141use vortex:: expr:: Expression ;
4242use vortex:: expr:: Pack ;
43- use vortex:: expr:: and;
4443use vortex:: expr:: and_collect;
4544use vortex:: expr:: col;
46- use vortex:: expr:: lit;
4745use vortex:: expr:: root;
4846use vortex:: expr:: select;
4947use vortex:: file:: OpenOptionsSessionExt ;
@@ -53,6 +51,7 @@ use vortex::io::runtime::BlockingRuntime;
5351use vortex:: io:: runtime:: current:: ThreadSafeIterator ;
5452use vortex:: layout:: layouts:: USE_VORTEX_OPERATORS ;
5553use vortex:: session:: VortexSession ;
54+ use vortex_utils:: aliases:: hash_set:: HashSet ;
5655
5756use crate :: RUNTIME ;
5857use crate :: SESSION ;
@@ -179,38 +178,32 @@ fn extract_table_filter_expr(
179178 init : & TableInitInput < VortexTableFunction > ,
180179 column_ids : & [ u64 ] ,
181180) -> VortexResult < Option < Expression > > {
182- let table_filter_expr = init
183- . table_filter_set ( )
184- . and_then ( |filter| {
185- filter
186- . into_iter ( )
187- . map ( |( idx, ex) | {
188- let idx_u: usize = idx. as_ ( ) ;
189- let col_idx: usize = column_ids[ idx_u] . as_ ( ) ;
190- let name = init
191- . bind_data ( )
192- . column_names
193- . get ( col_idx)
194- . vortex_expect ( "exists" ) ;
195- try_from_table_filter (
196- & ex,
197- & col ( name. as_str ( ) ) ,
198- init. bind_data ( ) . first_file . dtype ( ) ,
199- )
200- } )
201- . reduce ( |l, r| l?. zip ( r?) . map ( |( l, r) | Ok ( and ( l, r) ) ) . transpose ( ) )
202- } )
203- . transpose ( ) ?
204- . flatten ( ) ;
205-
206- let complex_filter_expr = and_collect ( init. bind_data ( ) . filter_exprs . clone ( ) ) ;
207- let filter_expr = complex_filter_expr
208- . into_iter ( )
209- . chain ( table_filter_expr)
210- . reduce ( and)
211- . unwrap_or_else ( || lit ( true ) ) ;
181+ let mut table_filter_exprs: HashSet < Expression > = if let Some ( filter) = init. table_filter_set ( )
182+ {
183+ filter
184+ . into_iter ( )
185+ . map ( |( idx, ex) | {
186+ let idx_u: usize = idx. as_ ( ) ;
187+ let col_idx: usize = column_ids[ idx_u] . as_ ( ) ;
188+ let name = init
189+ . bind_data ( )
190+ . column_names
191+ . get ( col_idx)
192+ . vortex_expect ( "exists" ) ;
193+ try_from_table_filter (
194+ & ex,
195+ & col ( name. as_str ( ) ) ,
196+ init. bind_data ( ) . first_file . dtype ( ) ,
197+ )
198+ } )
199+ . collect :: < VortexResult < Option < HashSet < _ > > > > ( ) ?
200+ . unwrap_or_else ( HashSet :: new)
201+ } else {
202+ HashSet :: new ( )
203+ } ;
212204
213- Ok ( Some ( filter_expr) )
205+ table_filter_exprs. extend ( init. bind_data ( ) . filter_exprs . clone ( ) ) ;
206+ Ok ( and_collect ( table_filter_exprs. into_iter ( ) . collect_vec ( ) ) )
214207}
215208
216209/// Helper function to open a Vortex file from either a local or S3 URL
0 commit comments