[python] Add schema short-circuit to SplitRead and FileScanner read paths#8217
Open
MgjLLL wants to merge 3 commits into
Open
[python] Add schema short-circuit to SplitRead and FileScanner read paths#8217MgjLLL wants to merge 3 commits into
MgjLLL wants to merge 3 commits into
Conversation
The schema short-circuit in FileScanner._schema_fields() returns table.table_schema.fields when schema_id matches the current schema id. The test fixture only mocked Mock(id=0) without .fields, causing the short-circuit path to return a Mock auto-attribute that is not iterable when used by SimpleStatsEvolutions._create_index_cast_mapping.
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.
Purpose
Fix redundant filesystem I/O in
SplitReadandFileScannerwhen reading schema.SplitReadhas 3 call sites that unconditionally callschema_manager.get_schema(schema_id)even whenschema_id == table.table_schema.id— the schema is already in memory. This causes unnecessary filesystem reads in the common case (no schema evolution).Java equivalent (
RawFileSplitRead.createFileReader()) short-circuits with:Changes
split_read.py: Add_resolve_schema()method that returns in-memory schema when id matches, replacing 3 directget_schema()calls inraw_reader_supplier,_get_fields_and_predicate, and_file_read_fieldsfile_scanner.py: Add_schema_fields()method with same short-circuit pattern forSimpleStatsEvolutionsTests
file_scanner_schema_fields_test.pywith 3 test cases covering short-circuit, delegation, and zero-id edge caseThis closes #8216