korowa commented on code in PR #2647:
URL: https://github.com/apache/arrow-datafusion/pull/2647#discussion_r887579087
##########
datafusion/core/src/optimizer/filter_push_down.rs:
##########
@@ -178,13 +177,35 @@ fn lr_is_preserved(plan: &LogicalPlan) -> (bool, bool) {
}
}
+// For a given JOIN logical plan, determine whether each side of the join is
preserved
+// in terms on join filtering.
+// Predicates from join filter can only be pushed to preserved join side.
+fn on_lr_is_preserved(plan: &LogicalPlan) -> (bool, bool) {
+ match plan {
+ LogicalPlan::Join(Join { join_type, .. }) => match join_type {
+ JoinType::Inner => (true, true),
+ JoinType::Left => (false, true),
+ JoinType::Right => (true, false),
+ JoinType::Full => (false, false),
+ // Semi/Anti joins can not have join filter.
+ JoinType::Semi | JoinType::Anti => unreachable!(
+ "on_lr_is_preserved cannot be appplied to SEMI/ANTI-JOIN nodes"
+ ),
+ },
+ LogicalPlan::CrossJoin(_) => {
+ unreachable!("on_lr_is_preserved cannot be applied to CROSSJOIN
nodes")
+ }
+ _ => unreachable!("on_lr_is_preserved only valid for JOIN nodes"),
+ }
+}
+
// Determine which predicates in state can be pushed down to a given side of a
join.
// To determine this, we need to know the schema of the relevant join side and
whether
// or not the side's rows are preserved when joining. If the side is not
preserved, we
// do not push down anything. Otherwise we can push down predicates where all
of the
// relevant columns are contained on the relevant join side's schema.
fn get_pushable_join_predicates<'a>(
- state: &'a State,
+ filters: &'a [(Expr, HashSet<Column>)],
Review Comment:
I've added `type Predicate` and replaced all tuples of expression and its
columns in signatures/attributes with it - hope it looks better.
--
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]