-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make PruningPredicate's rewrite public #12835
Conversation
/// Notice: Does not handle [`phys_expr::InListExpr`] greater than 20, which will fall back to calling `unhandled_hook` | ||
pub fn build_predicate_expression( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to new names. We could also make a wrapper that e.g. does not require required_columns
and takes Option<UnhandledPredicateHook>
which defaults to true
.
pub trait UnhandledPredicateHook { | ||
/// Called when a predicate can not be handled by DataFusion's transformation rules | ||
/// or is referencing a column that is not in the schema. | ||
fn handle(&self, expr: &Arc<dyn PhysicalExpr>) -> Arc<dyn PhysicalExpr>; | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
struct ConstantUnhandledPredicateHook { | ||
default: Arc<dyn PhysicalExpr>, | ||
} | ||
|
||
impl ConstantUnhandledPredicateHook { | ||
fn new(default: Arc<dyn PhysicalExpr>) -> Self { | ||
Self { default } | ||
} | ||
} | ||
|
||
impl UnhandledPredicateHook for ConstantUnhandledPredicateHook { | ||
fn handle(&self, _expr: &Arc<dyn PhysicalExpr>) -> Arc<dyn PhysicalExpr> { | ||
self.default.clone() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong feelings for naming these, I don't love the current names.
01274f9
to
a7e4b5b
Compare
a7e4b5b
to
9c49413
Compare
Sorry for the churn, closing in favor of #12850 |
Replaces #12606
As per #12606 (comment) the plan was to split the rewrite logic from the rest of PruningPredicate. It turns out that was as easy as making a function public, kudos to whoever wrote this originally for organizing it nicely 🥳.