Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datafusion/execution/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ impl Default for SessionConfig {
}

/// A type map for storing extensions.
///
///
/// Extensions are indexed by their type `T`. If multiple values of the same type are provided, only the last one
/// will be kept.
///
///
/// Extensions are opaque objects that are unknown to DataFusion itself but can be downcast by optimizer rules,
/// execution plans, or other components that have access to the session config.
/// They provide a flexible way to attach extra data or behavior to the session config.
Expand Down
15 changes: 13 additions & 2 deletions datafusion/physical-expr/src/simplifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ use datafusion_common::{
};
use std::sync::Arc;

use crate::PhysicalExpr;
use crate::{simplifier::not::simplify_not_expr_recursive, PhysicalExpr};

pub mod not;
pub mod unwrap_cast;

/// Simplifies physical expressions by applying various optimizations
Expand Down Expand Up @@ -56,6 +57,11 @@ impl<'a> TreeNodeRewriter for PhysicalExprSimplifier<'a> {
type Node = Arc<dyn PhysicalExpr>;

fn f_up(&mut self, node: Self::Node) -> Result<Transformed<Self::Node>> {
// Apply NOT expression simplification first
let not_simplified = simplify_not_expr_recursive(&node, self.schema)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the variable is a bit confusing - not_simplified. It sounds like it is not simplified.
Maybe rename it to not_expr_simplified ?!

let node = not_simplified.data;
let transformed = not_simplified.transformed;

// Apply unwrap cast optimization
#[cfg(test)]
let original_type = node.data_type(self.schema).unwrap();
Expand All @@ -66,7 +72,12 @@ impl<'a> TreeNodeRewriter for PhysicalExprSimplifier<'a> {
original_type,
"Simplified expression should have the same data type as the original"
);
Ok(unwrapped)
// Combine transformation results
let final_transformed = transformed || unwrapped.transformed;
Ok(Transformed::new_transformed(
unwrapped.data,
final_transformed,
))
}
}

Expand Down
Loading