Skip to content

Make PruningPredicate's rewrite public #12835

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

adriangb
Copy link
Contributor

@adriangb adriangb commented Oct 9, 2024

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 🥳.

@github-actions github-actions bot added the core Core DataFusion crate label Oct 9, 2024
Comment on lines 1359 to 1360
/// Notice: Does not handle [`phys_expr::InListExpr`] greater than 20, which will fall back to calling `unhandled_hook`
pub fn build_predicate_expression(
Copy link
Contributor Author

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.

Comment on lines +483 to +504
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()
}
}
Copy link
Contributor Author

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.

@adriangb adriangb force-pushed the rewrite-hook branch 2 times, most recently from 01274f9 to a7e4b5b Compare October 10, 2024 12:56
@adriangb
Copy link
Contributor Author

Sorry for the churn, closing in favor of #12850

@adriangb adriangb closed this Oct 10, 2024
@adriangb adriangb deleted the rewrite-hook branch October 10, 2024 13:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant