-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Allow struct field access projections to be pushed down into scans #19538
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
Open
adriangb
wants to merge
15
commits into
apache:main
Choose a base branch
from
pydantic:column-path-functions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,130
−86
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0e30d69
initial implementation of projection pushdown for nexted expressions
adriangb 2c838cb
fix lints, test
adriangb e5ac8bb
remove unused classes
adriangb af2569a
remove more functions
adriangb effeb66
add test, start working on getting it passing
adriangb 7943072
test passing
adriangb f859e17
fix
adriangb 8259b12
attempt to split projections
adriangb 14f33fe
clippy
adriangb 22b6c7d
fix: only push projections through operators when beneficial
adriangb c2bd92d
fix bug, update slt
adriangb 1a5355b
fmt
adriangb 1d6babe
try to fix
adriangb a68ddbb
use triviality enum
adriangb a932c74
revert unchanged files
adriangb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| //! Triviality classification for expressions and function arguments. | ||
|
|
||
| /// Classification of argument triviality for scalar functions. | ||
| /// | ||
| /// This enum is used by [`ScalarUDFImpl::triviality_with_args`] to allow | ||
| /// functions to make context-dependent decisions about whether they are | ||
| /// trivial based on the nature of their arguments. | ||
| /// | ||
| /// For example, `get_field(struct_col, 'field_name')` is trivial (static field | ||
| /// lookup), but `get_field(struct_col, key_col)` is not (dynamic per-row lookup). | ||
| /// | ||
| /// [`ScalarUDFImpl::triviality_with_args`]: crate::ScalarUDFImpl::triviality_with_args | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub enum ArgTriviality { | ||
| /// Argument is a literal constant value or an expression that can be | ||
| /// evaluated to a constant at planning time. | ||
| Literal, | ||
| /// Argument is a simple column reference. | ||
| Column, | ||
| /// Argument is a complex expressions that declares itself trivial. | ||
| /// For example, if `get_field(struct_col, 'field_name')` is implemented as a | ||
| /// trivial expression, then it would return this variant. | ||
| /// Then `other_trivial_function(get_field(...), 42)` could also be classified as | ||
| /// a trivial expression using the knowledge that `get_field(...)` is trivial. | ||
| TrivialExpr, | ||
| /// Argument is a complex expression that declares itself non-trivial. | ||
| /// For example, `min(col1 + col2)` is non-trivial because it requires per-row computation. | ||
| NonTrivial, | ||
| } | ||
|
|
||
| impl ArgTriviality { | ||
| /// Returns true if this triviality classification indicates a trivial | ||
| /// (cheap to evaluate) expression. | ||
| /// | ||
| /// Trivial expressions include literals, column references, and trivial | ||
| /// composite expressions like nested field accessors. | ||
| pub fn is_trivial(&self) -> bool { | ||
| !matches!(self, ArgTriviality::NonTrivial) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is somewhat interesting that it materializes the constant in the scan. This is probably ok, but it does mean that constant may now get carried as a constant record batch up through the plan many 🤔