Skip to content

Commit

Permalink
bound to 1%
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-ho committed Jan 16, 2025
1 parent 4b67e5a commit 672396e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/daft-dsl/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ pub fn count_actor_pool_udfs(exprs: &[ExprRef]) -> usize {
}

pub fn estimated_selectivity(expr: &Expr, schema: &Schema) -> f64 {
match expr {
let estimate = match expr {
// Boolean operations that filter rows
Expr::BinaryOp { op, left, right } => {
let left_selectivity = estimated_selectivity(left, schema);
Expand Down Expand Up @@ -1406,5 +1406,8 @@ pub fn estimated_selectivity(expr: &Expr, schema: &Schema) -> f64 {
// Everything else doesn't filter
Expr::Subquery(_) => 1.0,
Expr::Agg(_) => panic!("Aggregates are not allowed in WHERE clauses"),
}
};

// Lower bound to 1% to prevent overly selective estimate
estimate.max(0.01)
}

0 comments on commit 672396e

Please sign in to comment.