@@ -466,7 +466,7 @@ impl IndexJoin {
466466 // For the same reason the compiler also ensures this unwrap is safe.
467467 let probe_column = self . probe_side . source . head ( ) . column ( & self . probe_field ) . unwrap ( ) . col_id ;
468468 match self . index_side {
469- Table :: MemTable ( delta) if self . return_index_rows => {
469+ Table :: MemTable ( delta) => {
470470 let index_field = field ( & delta, & self . index_col ) ;
471471
472472 // Merge all selections from the original probe side into a single predicate.
@@ -480,25 +480,7 @@ impl IndexJoin {
480480 }
481481 } )
482482 } ) ;
483- IndexJoin {
484- // The new probe side consists of the updated rows.
485- probe_side : delta. into ( ) ,
486- // The new probe field is the previous index field.
487- probe_field : index_field,
488- // The original probe table is now the table that is being probed.
489- index_side : self . probe_side . source . into ( ) ,
490- // Any selections from the original probe side are pulled above the index lookup.
491- index_select : predicate,
492- // The new index field is the previous probe field.
493- index_col : probe_column,
494- // Because we have swapped the original index and probe sides of the join,
495- // the new index join needs to return rows from the probe side instead of the index side.
496- return_index_rows : false ,
497- }
498- }
499- Table :: MemTable ( delta) => {
500- let index_field = field ( & delta, & self . index_col ) ;
501-
483+ // Push any selections on the index side to the probe side.
502484 let probe_side = if let Some ( predicate) = self . index_select {
503485 QueryExpr {
504486 source : delta. into ( ) ,
@@ -515,13 +497,13 @@ impl IndexJoin {
515497 probe_field : index_field,
516498 // The original probe table is now the table that is being probed.
517499 index_side : self . probe_side . source . into ( ) ,
518- // Any selections from the index probe side are pushed to the probe side .
519- index_select : None ,
500+ // Any selections from the original probe side are pulled above the index lookup .
501+ index_select : predicate ,
520502 // The new index field is the previous probe field.
521503 index_col : probe_column,
522504 // Because we have swapped the original index and probe sides of the join,
523- // the new index join needs to return rows from the index side instead of the probe side.
524- return_index_rows : true ,
505+ // the new index join needs to return rows from the opposite side.
506+ return_index_rows : ! self . return_index_rows ,
525507 }
526508 }
527509 Table :: DbTable ( _) => self ,
0 commit comments