Spark: Read variant columns through the row reader to avoid a shredded vectorization failure - #17736
Open
nssalian wants to merge 2 commits into
Open
Spark: Read variant columns through the row reader to avoid a shredded vectorization failure#17736nssalian wants to merge 2 commits into
nssalian wants to merge 2 commits into
Conversation
…d-variant vectorization crash
nssalian
marked this pull request as ready for review
August 20, 2026 02:30
Collaborator
Author
|
Failures seems from maven, needs a re-run |
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.
Rationale for this change
In my testing, I found that Vectorized Parquet reads throw
UnsupportedOperationExceptionwhen they hit a shredded variant column (typed_valuesubtree).SparkBatchtried to route shredded files away from the vectorized reader using the manifest variant bounds and thewrite.parquet.shred-variantsproperty, but neither is sound. Bounds are optional (a file written with metricsnone/countscarries none), and the property reflects writer intent, not how existing files were written. Shredding can also be enabled through the session conf or a write option with the table property left false. A shredded file can therefore reach the vectorized reader and crash, and it cannot be detected soundly at plan time, since shredding is a per-file Parquet-footer fact that is not recorded in the manifest.After checking all possible options, this seemed like the easiest to do to avoid any edge cases. Follow up section has more.
Changes
Spark 4.0 and 4.1: Route variant columns to the row reader in the batch path for now.
SparkBatch.supportsParquetBatchReadsnow returns false for any variant column, and the unsound bounds and property/metrics checks are removed. A query that projects a variant column reads through the row reader, which reconstructs both shredded and unshredded variants correctly. Queries that do not project a variant column are unaffected and still vectorize.Also, SparkScanBuilder no longer force-loads column stats for variant columns on read, since that plumbing existed only to feed the removed bounds check.
Testing
Added
testReadShreddedViaSessionConfWithoutTableProperty(v4.0 and v4.1). It enables shredding through the session conf with the table property left false and metrics disabled, then reads under vectorization and asserts the variant values are correct. On the previous routing the shredded file reached the vectorized reader and threwUnsupportedOperationException, so the test failed; with this change it reads through the row reader and passes. It guards against the crash returning: any routing that lets a shredded file reach the vectorized reader again fails the read, and the test.Follow up
This turns off vectorized reads for variant columns, including unshredded ones, since plan time cannot tell them apart. The follow-up is to write the vectorized reader to reconstruct shredded variants, which lets variant vectorize again for both shredded and unshredded data in a subsequent release. This is a more involved work that will take a while so disabling this for now until that can go in. I'll open the fix in parts soon.