Skip to content

Conversation

@Tishj
Copy link
Owner

@Tishj Tishj commented Nov 28, 2025

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 unchanged

Storage:

We push down scan_child_column booleans, 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_extract function takes out the field it needs.

New Behavior

Expression:

The struct_extract(s, 'a') is replaced with a new BoundColumnRefExpression, referencing the field we emit directly from the LogicalGet

Storage:

We don't emit a STRUCT column 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 BoundReferenceExpression just references the field that was emitted directly by the storage.

Technical details

We communicate this new "pushdown extract" behavior through the ColumnIndex down to the StorageIndex, as well as the LogicalType of 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.

Tishj and others added 30 commits December 8, 2025 17:01
…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
…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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants