Skip to content

Commit 83736ef

Browse files
authored
Fix PruningPredicate interaction with DynamicFilterPhysicalExpr that references partition columns (#19129)
- Fix handling of DynamicFilterPhysicalExpr that references partition columns - Adds some integration tests for handling of literal expression trees, making sure that if they are passed through `PhysicalExprSimplifier` before `PruningPredicate` we are able to prune. - Refactors internal tracking of column counts to short circuit early and make match logic easier to follow
1 parent ab7fe0e commit 83736ef

File tree

2 files changed

+307
-24
lines changed

2 files changed

+307
-24
lines changed

datafusion/physical-expr-common/src/physical_expr.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,14 +579,32 @@ pub fn fmt_sql(expr: &dyn PhysicalExpr) -> impl Display + '_ {
579579
pub fn snapshot_physical_expr(
580580
expr: Arc<dyn PhysicalExpr>,
581581
) -> Result<Arc<dyn PhysicalExpr>> {
582+
snapshot_physical_expr_opt(expr).data()
583+
}
584+
585+
/// Take a snapshot of the given `PhysicalExpr` if it is dynamic.
586+
///
587+
/// Take a snapshot of this `PhysicalExpr` if it is dynamic.
588+
/// This is used to capture the current state of `PhysicalExpr`s that may contain
589+
/// dynamic references to other operators in order to serialize it over the wire
590+
/// or treat it via downcast matching.
591+
///
592+
/// See the documentation of [`PhysicalExpr::snapshot`] for more details.
593+
///
594+
/// # Returns
595+
///
596+
/// Returns a `[`Transformed`] indicating whether a snapshot was taken,
597+
/// along with the resulting `PhysicalExpr`.
598+
pub fn snapshot_physical_expr_opt(
599+
expr: Arc<dyn PhysicalExpr>,
600+
) -> Result<Transformed<Arc<dyn PhysicalExpr>>> {
582601
expr.transform_up(|e| {
583602
if let Some(snapshot) = e.snapshot()? {
584603
Ok(Transformed::yes(snapshot))
585604
} else {
586605
Ok(Transformed::no(Arc::clone(&e)))
587606
}
588607
})
589-
.data()
590608
}
591609

592610
/// Check the generation of this `PhysicalExpr`.

0 commit comments

Comments
 (0)