Skip to content

Commit 7ee2bfb

Browse files
committed
remove special handling for unknown column
1 parent 22981aa commit 7ee2bfb

3 files changed

Lines changed: 10 additions & 18 deletions

File tree

‎datafusion/physical-plan/src/filter_pushdown.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ use std::collections::HashSet;
3838
use std::sync::Arc;
3939

4040
use datafusion_common::Result;
41-
use datafusion_physical_expr::utils::{
42-
collect_columns, reassign_expr_columns,
43-
};
41+
use datafusion_physical_expr::utils::{collect_columns, reassign_expr_columns};
4442
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
4543
use itertools::Itertools;
4644

‎datafusion/physical-plan/src/projection.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,10 +1634,10 @@ mod tests {
16341634

16351635
let pushed_filters = &description.parent_filters()[0];
16361636
assert!(matches!(pushed_filters[0].discriminant, PushedDown::No));
1637-
// The column shouldn't be found in the alias map, so it should become UnKnownColumn
1637+
// The column shouldn't be found in the alias map, so it's left unchanged
16381638
assert_eq!(
16391639
format!("{}", pushed_filters[0].predicate),
1640-
"unknown_col > 5"
1640+
"unknown_col@1 > 5"
16411641
);
16421642

16431643
Ok(())

‎datafusion/physical-plan/src/util.rs‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ use datafusion_common::{
2121
HashMap,
2222
tree_node::{Transformed, TreeNodeRecursion, TreeNodeRewriter},
2323
};
24-
use datafusion_physical_expr::{
25-
PhysicalExpr,
26-
expressions::Column,
27-
};
24+
use datafusion_physical_expr::{PhysicalExpr, expressions::Column};
2825

2926
/// Rewrite column references in a physical expr according to a mapping.
3027
///
3128
/// This rewriter traverses the expression tree and replaces [`Column`] nodes
3229
/// with the corresponding expression found in the `column_map`.
3330
///
3431
/// If a column is found in the map, it is replaced by the mapped expression.
35-
/// If a column is NOT found in the ma an error is returned.
32+
/// If a column is NOT found in the map, it is left unchanged.
3633
pub struct PhysicalColumnRewriter {
3734
/// Mapping from original column to new column.
3835
pub column_map: HashMap<Column, Arc<dyn PhysicalExpr>>,
@@ -60,11 +57,8 @@ impl TreeNodeRewriter for PhysicalColumnRewriter {
6057
true,
6158
TreeNodeRecursion::Jump,
6259
));
63-
} else {
64-
return Err(datafusion_common::error::DataFusionError::Plan(
65-
format!("Column {:?} not found in column map", column),
66-
));
6760
}
61+
// Column not in map - leave unchanged
6862
}
6963
Ok(Transformed::no(node))
7064
}
@@ -158,7 +152,7 @@ mod tests {
158152

159153
assert_eq!(
160154
format!("{}", result.data),
161-
"(42 + replaced_b) * (c - d) + e"
155+
"(42 + replaced_b) * (c@2 - d@3) + e@4"
162156
);
163157

164158
Ok(())
@@ -192,7 +186,7 @@ mod tests {
192186

193187
assert_eq!(
194188
format!("{}", result.data),
195-
"a + b + 100 + new_col@5 + d + e"
189+
"a@0 + b@1 + 100 + new_col@5 + d@3 + e@4"
196190
);
197191

198192
Ok(())
@@ -253,7 +247,7 @@ mod tests {
253247

254248
// Verify transformation occurred
255249
assert!(result.transformed);
256-
assert_eq!(format!("{}", result.data), "(10 + b) * (20 - d) + 30");
250+
assert_eq!(format!("{}", result.data), "(10 + b@1) * (20 - d@3) + 30");
257251

258252
Ok(())
259253
}
@@ -307,7 +301,7 @@ mod tests {
307301

308302
assert_eq!(
309303
format!("{}", result.data),
310-
"5 * a@0 + 3 - another_col@7 + b"
304+
"5 * a@0 + 3 - another_col@7 + b@1"
311305
);
312306

313307
// Verify transformation occurred

0 commit comments

Comments
 (0)