Repository navigation
perf(substrait): avoid quadratic field lookup when consuming ReadRel - #26190
Open
ole-baranov wants to merge 1 commit into
Open
ole-baranov wants to merge 1 commit into
ole-baranov wants to merge 1 commit into
Conversation
`ensure_schema_compatibility` and `apply_projection` looked up every field
of the Substrait base schema with a linear scan of the table schema, making
consumption of a read over a wide table O(m*n). Build a name->index map of
the table schema once instead. Missing or duplicated names fall back to the
existing DFSchema lookups, so errors and disambiguation are unchanged.
Add a `consume_wide_read` benchmark. Consume time for `SELECT c0` over a
table with N columns:
columns before after
100 58 us 25.5 us
1000 2.33 ms 276 us
10000 211 ms 3.16 ms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bvolpato
approved these changes
Oct 11, 2026
bvolpato
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks for the improvement. The fast path preserves the existing lookup fallback for missing and duplicate names. Substrait checks, Clippy, and the wide-read benchmark smoke run pass locally.
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.
ensure_schema_compatibilityandapply_projectionlooked up every field of the Substrait base schema with a linear scan of the table schema, making consumption of a read over a wide table O(m*n). Build a name->index map of the table schema once instead. Missing or duplicated names fall back to the existing DFSchema lookups, so errors and disambiguation are unchanged.Add a
consume_wide_readbenchmark. Consume time forSELECT c0over a table with N columns: