Skip to content

Commit a618a2e

Browse files
committed
Stop copying LogicalPlan and Exprs in PushDownFilter
1 parent cf0cba7 commit a618a2e

File tree

3 files changed

+363
-288
lines changed

3 files changed

+363
-288
lines changed

datafusion/expr/src/expr.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,28 @@ impl Expr {
12751275
}
12761276
}
12771277

1278+
/// Return a reference to the inner `Column` if any
1279+
///
1280+
/// returns `None` if the expression is not a `Column`
1281+
///
1282+
/// Example
1283+
/// ```
1284+
/// # use datafusion_common::Column;
1285+
/// use datafusion_expr::{col, Expr};
1286+
/// let expr = col("foo");
1287+
/// assert_eq!(expr.try_as_col(), Some(&Column::from("foo")));
1288+
///
1289+
/// let expr = col("foo").alias("bar");
1290+
/// assert_eq!(expr.try_as_col(), None);
1291+
/// ```
1292+
pub fn try_as_col(&self) -> Option<&Column> {
1293+
if let Expr::Column(it) = self {
1294+
Some(it)
1295+
} else {
1296+
None
1297+
}
1298+
}
1299+
12781300
/// Return all referenced columns of this expression.
12791301
pub fn to_columns(&self) -> Result<HashSet<Column>> {
12801302
let mut using_columns = HashSet::new();

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,16 @@ pub enum Distinct {
23532353
On(DistinctOn),
23542354
}
23552355

2356+
impl Distinct {
2357+
/// return a reference to the nodes input
2358+
pub fn input(&self) -> &Arc<LogicalPlan> {
2359+
match self {
2360+
Distinct::All(input) => input,
2361+
Distinct::On(DistinctOn { input, .. }) => input,
2362+
}
2363+
}
2364+
}
2365+
23562366
/// Removes duplicate rows from the input
23572367
#[derive(Clone, PartialEq, Eq, Hash)]
23582368
pub struct DistinctOn {

0 commit comments

Comments
 (0)