Skip to content

Commit d318324

Browse files
authored
PushdownFilter optimizations (apache#21668)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Addresses apache#20002 - Includes apache#21643 - Looks like we had a similar idea with apache#21667, cc @kumarUjjawal - [x] I like the name `try_unchecked` more so I would adopt that - I'm not sure if we need to keep the unaliasing, the optimizer rule already does that - I have additional changes for more aggressive optimizations, so I'm happy to combine the PRs or rebase after merge ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? - Add a hidden `Filter::new` constructor that skips type-checking - Less allocations, more modification of mutable plan nodes - Less cloning, use references when possible ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Relying on existing tests mostly, added a few more tests. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> `make_filter` is deprecated, probably wasn't meant to be a public function.
1 parent 0da8961 commit d318324

4 files changed

Lines changed: 306 additions & 335 deletions

File tree

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,19 @@ pub struct Filter {
24952495
}
24962496

24972497
impl Filter {
2498+
/// Create a new filter operator.
2499+
///
2500+
/// Skips the type-checking and dealiasing done in [Self::try_new].
2501+
/// For internal use in DataFusion only.
2502+
///
2503+
/// **Preconditions:**
2504+
/// - the `predicate` expression returns a boolean value
2505+
/// - the `predicate` expression is not aliased
2506+
#[doc(hidden)]
2507+
pub fn new(predicate: Expr, input: Arc<LogicalPlan>) -> Self {
2508+
Self { predicate, input }
2509+
}
2510+
24982511
/// Create a new filter operator.
24992512
///
25002513
/// Notes: as Aliases have no effect on the output of a filter operator,

0 commit comments

Comments
 (0)