Skip to content

Commit 8db87e3

Browse files
committed
Use Filter::new_unchecked
1 parent 7b33613 commit 8db87e3

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
@@ -2486,7 +2486,7 @@ impl Filter {
24862486
/// Skips the type-checking and dealiasing done in [Self::try_new].
24872487
/// For internal use in DataFusion only.
24882488
#[doc(hidden)]
2489-
pub fn new(predicate: Expr, input: Arc<LogicalPlan>) -> Self {
2489+
pub fn new_unchecked(predicate: Expr, input: Arc<LogicalPlan>) -> Self {
24902490
Self { predicate, input }
24912491
}
24922492

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,15 @@ fn push_down_all_join(
497497
}
498498

499499
if let Some(predicate) = conjunction(left_push) {
500-
join.left = Arc::new(LogicalPlan::Filter(Filter::new(predicate, join.left)));
500+
join.left = Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
501+
predicate, join.left,
502+
)));
501503
}
502504

503505
if let Some(predicate) = conjunction(right_push) {
504-
join.right = Arc::new(LogicalPlan::Filter(Filter::new(predicate, join.right)));
506+
join.right = Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
507+
predicate, join.right,
508+
)));
505509
}
506510

507511
// Add any new join conditions as the non join predicates
@@ -960,7 +964,7 @@ impl OptimizerRule for PushDownFilter {
960964

961965
let push_predicate =
962966
replace_cols_by_name(filter.predicate.clone(), &replace_map)?;
963-
inputs.push(Arc::new(LogicalPlan::Filter(Filter::new(
967+
inputs.push(Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
964968
push_predicate,
965969
input,
966970
))))
@@ -1212,7 +1216,7 @@ impl OptimizerRule for PushDownFilter {
12121216
.inputs()
12131217
.into_iter()
12141218
.map(|child| {
1215-
LogicalPlan::Filter(Filter::new(
1219+
LogicalPlan::Filter(Filter::new_unchecked(
12161220
predicate.clone(),
12171221
Arc::new(child.clone()),
12181222
))
@@ -1295,7 +1299,7 @@ fn rewrite_projection(
12951299
let projection = if let Some(expr) = conjunction(push_predicates) {
12961300
// re-write all filters based on this projection
12971301
// E.g. in `Filter: b\n Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
1298-
projection.input = Arc::new(LogicalPlan::Filter(Filter::new(
1302+
projection.input = Arc::new(LogicalPlan::Filter(Filter::new_unchecked(
12991303
replace_cols_by_name(expr, &pushable_map)?,
13001304
projection.input,
13011305
)));
@@ -1376,7 +1380,7 @@ fn contain<T>(expr: &Expr, check_map: &HashMap<String, T>) -> bool {
13761380

13771381
fn with_filters(predicates: Vec<Expr>, plan: LogicalPlan) -> LogicalPlan {
13781382
if let Some(predicate) = conjunction(predicates) {
1379-
LogicalPlan::Filter(Filter::new(predicate, Arc::new(plan)))
1383+
LogicalPlan::Filter(Filter::new_unchecked(predicate, Arc::new(plan)))
13801384
} else {
13811385
plan
13821386
}

0 commit comments

Comments
 (0)