-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support simplify not for physical expr #18970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c01c335
a0116ce
0d075ba
ceb85ff
be077db
27c4ef1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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)?; | ||
| 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(); | ||
|
alamb marked this conversation as resolved.
|
||
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can use So something like // Apply NOT expression simplification first
let rewritten =
simplify_not_expr(&node, self.schema)?.transform_data(|node| {
unwrap_cast::unwrap_cast_in_comparison(node, self.schema)
})?;That handles combining the transformed flag for you
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. neat, done in be077db. Need to catch up on the tree node APIs, haha |
||
| Ok(Transformed::new_transformed( | ||
| unwrapped.data, | ||
| final_transformed, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.