alamb commented on code in PR #4760:
URL: https://github.com/apache/arrow-datafusion/pull/4760#discussion_r1059478596
##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -17,13 +17,17 @@
//! Optimizer rule to extract equijoin expr from filter
use crate::optimizer::ApplyOrder;
+use crate::utils::split_conjunction;
use crate::{OptimizerConfig, OptimizerRule};
use datafusion_common::DFSchema;
use datafusion_common::Result;
use datafusion_expr::utils::{can_hash, find_valid_equijoin_key_pair};
use datafusion_expr::{BinaryExpr, Expr, ExprSchemable, Join, LogicalPlan,
Operator};
use std::sync::Arc;
+// equijoin predicate
+type EquijoinPredicate = (Expr, Expr);
Review Comment:
❤️
##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -100,30 +99,22 @@ impl OptimizerRule for ExtractEquijoinPredicate {
}
}
-/// Extracts equijoin ON condition be a single Eq or multiple conjunctive Eqs
-/// Filters matching this pattern are added to `accum`
-/// Filters that don't match this pattern are added to `accum_filter`
-/// Examples:
-/// ```text
-/// foo = bar => accum=[(foo, bar)] accum_filter=[]
-/// foo = bar AND bar = baz => accum=[(foo, bar), (bar, baz)] accum_filter=[]
-/// foo = bar AND baz > 1 => accum=[(foo, bar)] accum_filter=[baz > 1]
-///
-/// For equijoin join key, assume we have tables -- a(c0, c1 c2) and b(c0, c1,
c2):
-/// (a.c0 = 10) => accum=[], accum_filter=[a.c0 = 10]
-/// (a.c0 + 1 = b.c0 * 2) => accum=[(a.c0 + 1, b.c0 * 2)], accum_filter=[]
-/// (a.c0 + b.c0 = 10) => accum=[], accum_filter=[a.c0 + b.c0 = 10]
-/// ```
-fn extract_join_keys(
- expr: Expr,
- accum: &mut Vec<(Expr, Expr)>,
- accum_filter: &mut Vec<Expr>,
+fn split_eq_and_noneq_join_predicate(
+ filter: &Expr,
left_schema: &Arc<DFSchema>,
right_schema: &Arc<DFSchema>,
-) -> Result<()> {
- match &expr {
- Expr::BinaryExpr(BinaryExpr { left, op, right }) => match op {
- Operator::Eq => {
+) -> Result<(Vec<EquijoinPredicate>, Option<Expr>)> {
Review Comment:
this is a much nicer interface 👍 for being self documenting
--
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]