MidasLamb commented on issue #6744:
URL: 
https://github.com/apache/arrow-datafusion/issues/6744#issuecomment-1609521816

   I've found this piece of comment/code in the `EliminateCrossJoin` optimizer:
   ```rust
   // The filter of inner join will lost, skip this rule.
   // issue: https://github.com/apache/arrow-datafusion/issues/4844
   if join.filter.is_some() {
       return Ok(None);
   }
   ```
   However in my scenario the filtered join is not the top level, so that 
checks seems to get skipped.
   
   I've set up a test for this by doing this:
   ```rust
           let t1 = test_table_scan_with_name("t1")?;
           let t2 = test_table_scan_with_name("t2")?;
           let t3 = test_table_scan_with_name("t3")?;
   
           // could eliminate to inner join since filter has Join predicates
           let plan = LogicalPlanBuilder::from(t1)
               .join(t2, JoinType::Inner, (Vec::<Column>::new(), 
Vec::<Column>::new()), Some(col("t1.a").eq(col("t2.a"))))?
               .join(
                   t3,
                   JoinType::Inner,
                   (
                       vec![Column::from_qualified_name("t2.a")],
                       vec![Column::from_qualified_name("t3.a")],
                   ),
                   None,
               )?
               .filter(col("t2.c").lt(lit(20u32)))?
               .build()?;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to