Unify arrow exports across all query result types#495
Merged
evertlammerts merged 5 commits intoJun 16, 2026
Merged
Conversation
…with a live connection / transaction
2 tasks
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
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 unifies arrow exports across query result types, and makes sure we always provide the schema from within a transaction.
We are dealing with 3 arrow export types:
... across 3 result types:
The
StreamingQueryResultpaths are now unified. We re-feed the backing ColumnDataCollection to the engine for parallel conversion into aArrowQueryResult, and then we delegate to the correspondingArrowQueryResultpath.The
ArrowQueryResultpaths deal with materialized data already, and we have no way to plug into the transaction that generated it. The actual fix for this is to cache the schema when creating theArrowQueryResult, duringFinalize. This is a core change that we will probably apply in v2.0. The workaround is to fetch the schema in a separate transaction. For all paths, since we are already dealing with materialized data, we create an arrow table. Then for the streaming paths we return the corresponding stream types directly from the table.The
StreamingQueryResultpaths always have access to a valid transaction context, and can get the arrow schema on demand even when that requires catalog access.As a side effect of this PR, consuming an arrow c stream (reading from
con.sql(q).__arrow_c_stream__()) is now lazy, i.e. not materialized. This makes consumption of course slower, but allows streaming much larger datasets.The materialized paths are overall a little faster, and the non-c stream streaming paths as well.
Fixes #475