Skip to content

Commit d837e3d

Browse files
committed
Use Filter::new_unchecked
1 parent 9be5b52 commit d837e3d

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,7 @@ impl Filter {
24892489
/// Skips the type-checking and dealiasing done in [Self::try_new].
24902490
/// For internal use in DataFusion only.
24912491
#[doc(hidden)]
2492-
pub fn new(predicate: Expr, input: Arc<LogicalPlan>) -> Self {
2492+
pub fn new_unchecked(predicate: Expr, input: Arc<LogicalPlan>) -> Self {
24932493
Self { predicate, input }
24942494
}
24952495

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,15 @@ fn push_down_all_join(
500500
}
501501

502502
if let Some(predicate) = conjunction(left_push) {
503-
join.left = Arc::new(LogicalPlan::Filter(Filter::new(predicate, join.left)));
503+
join.left = Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
504+
predicate, join.left,
505+
)));
504506
}
505507

506508
if let Some(predicate) = conjunction(right_push) {
507-
join.right = Arc::new(LogicalPlan::Filter(Filter::new(predicate, join.right)));
509+
join.right = Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
510+
predicate, join.right,
511+
)));
508512
}
509513

510514
// Add any new join conditions as the non join predicates
@@ -963,7 +967,7 @@ impl OptimizerRule for PushDownFilter {
963967

964968
let push_predicate =
965969
replace_cols_by_name(filter.predicate.clone(), &replace_map)?;
966-
inputs.push(Arc::new(LogicalPlan::Filter(Filter::new(
970+
inputs.push(Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
967971
push_predicate,
968972
input,
969973
))))
@@ -1225,7 +1229,7 @@ impl OptimizerRule for PushDownFilter {
12251229
.inputs()
12261230
.into_iter()
12271231
.map(|child| {
1228-
LogicalPlan::Filter(Filter::new(
1232+
LogicalPlan::Filter(Filter::new_unchecked(
12291233
predicate.clone(),
12301234
Arc::new(child.clone()),
12311235
))
@@ -1308,7 +1312,7 @@ fn rewrite_projection(
13081312
let projection = if let Some(expr) = conjunction(push_predicates) {
13091313
// re-write all filters based on this projection
13101314
// E.g. in `Filter: b\n Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
1311-
projection.input = Arc::new(LogicalPlan::Filter(Filter::new(
1315+
projection.input = Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
13121316
replace_cols_by_name(expr, &pushable_map)?,
13131317
projection.input,
13141318
)));
@@ -1389,7 +1393,7 @@ fn contain<T>(expr: &Expr, check_map: &HashMap<String, T>) -> bool {
13891393

13901394
fn with_filters(predicates: Vec<Expr>, plan: LogicalPlan) -> LogicalPlan {
13911395
if let Some(predicate) = conjunction(predicates) {
1392-
LogicalPlan::Filter(Filter::new(predicate, Arc::new(plan)))
1396+
LogicalPlan::Filter(Filter::new_unchecked(predicate, Arc::new(plan)))
13931397
} else {
13941398
plan
13951399
}

0 commit comments

Comments
 (0)