forked from duckdb/duckdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Struct projection pushdown v2 #148
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
Tishj
wants to merge
93
commits into
main
Choose a base branch
from
struct_projection_pushdown_v2
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.
Open
Conversation
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
…ming it directly in the storage
…rded in the transform to StorageIndex
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
Tishj
commented
Nov 29, 2025
…h it inside the StructColumnData explicitly, based on the StorageIndex we save in the ColumnScanState
…eFields method, handle the differing behavior through a callback
…that requires lazy replacement of the expressions, instead of the eager replacement we're doing now
…n logic in a single location
…ushing down extract expressions
…call RewriteExpressions to break up the struct references into separate struct extracts
…ust distill the set from the 'child_columns' at the end
…nging the prototype of the entire FetchRow virtual method
… ColumnData::CheckZonemap
…we can just distill the set from the 'child_columns' at the end" This reverts commit 14240bf.
…tically be disabled if 'statistics_extended' is not available
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR changes the struct projection pushdown to push the extract down to the storage.
I'll explain the differences in the different levels:
Current Behavior
Expression:
The
struct_extract(s, 'a')expression remains unchangedStorage:
We push down
scan_child_columnbooleans, to indicate which fields are left unread from the STRUCT.The fields that aren't touched are left empty (null) so we skip reading them.
What is emitted from the storage is a column of type STRUCT.
Execution:
The execution of the
struct_extractfunction takes out the field it needs.New Behavior
Expression:
The
struct_extract(s, 'a')is replaced with a newBoundColumnRefExpression, referencing the field we emit directly from theLogicalGetStorage:
We don't emit a
STRUCTcolumn if only a subset of the fields are needed by the query, instead we emit the individually referenced field(s)What is emitted from the storage is now a column of the type of the field.
Execution:
The
BoundReferenceExpressionjust references the field that was emitted directly by the storage.Technical details
We communicate this new "pushdown extract" behavior through the
ColumnIndexdown to theStorageIndex, as well as theLogicalTypeof the field we're scanning.Limitations
We disable the pushdown of the extract if fields of the struct are referenced by a filter.
To make that work correctly, we would need to rewrite the TableFilterSet, which I suspect has far-reaching consequences I'm not ready to deal with yet.