Skip to content

Commit

Permalink
fix: filter pushdown over table scan
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-spacetime committed Dec 16, 2024
1 parent a978ebe commit 292f9fc
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions crates/physical-plan/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,15 @@ impl RewriteRule for PushEqFilter {
fn matches(plan: &PhysicalPlan) -> Option<Self::Info> {
if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(BinOp::Eq, expr, value)) = plan {
if let (PhysicalExpr::Field(ProjectField { var, .. }), PhysicalExpr::Value(_)) = (&**expr, &**value) {
return input
.any(&|plan| match plan {
PhysicalPlan::TableScan(_, label) => label == var,
_ => false,
})
.then_some(*var);
return match &**input {
PhysicalPlan::TableScan(..) => None,
input => input
.any(&|plan| match plan {
PhysicalPlan::TableScan(_, label) => label == var,
_ => false,
})
.then_some(*var),
};
}
}
None
Expand Down Expand Up @@ -825,12 +828,15 @@ impl RewriteRule for PushConjunction {
if let PhysicalExpr::BinOp(BinOp::Eq, expr, value) = expr {
if let (PhysicalExpr::Field(ProjectField { var, .. }), PhysicalExpr::Value(_)) = (&**expr, &**value)
{
return input
.any(&|plan| match plan {
PhysicalPlan::TableScan(_, label) => label == var,
_ => false,
})
.then_some(*var);
return match &**input {
PhysicalPlan::TableScan(..) => None,
input => input
.any(&|plan| match plan {
PhysicalPlan::TableScan(_, label) => label == var,
_ => false,
})
.then_some(*var),
};
}
}
None
Expand Down

0 comments on commit 292f9fc

Please sign in to comment.