[SPARK-57591][SQL] Read and infer ORC schema from archives - #57615
Open
akshatshenoi-db wants to merge 2 commits into
Open
[SPARK-57591][SQL] Read and infer ORC schema from archives#57615akshatshenoi-db wants to merge 2 commits into
akshatshenoi-db wants to merge 2 commits into
Conversation
akshatshenoi-db
force-pushed
the
archive-orc
branch
from
July 28, 2026 22:09
480a6ca to
95bc456
Compare
…n and reword comment
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.
What changes were proposed in this pull request?
This extends the archive-reader feature to the ORC data source, so a
.tar/.tar.gz/.tgz/.zip/.7zarchive of ORC files is read as if it were a directory of the entries it contains, gated byspark.sql.files.archive.reader.enabled(default false). It follows the series that added archive support to CSV (SPARK-57135, SPARK-57321), JSON (SPARK-57419), text (SPARK-57478), XML (SPARK-57479), Avro (SPARK-57481), the zip container (SPARK-57705), theSupportsArchiveFormattrait extraction (SPARK-58110), and Parquet (SPARK-57590).ORC is a random-access format like Parquet: a footer read needs the whole file on disk, so it cannot be streamed entry-by-entry. It consumes the random-access surface already on the
SupportsArchiveFormattrait (added by the Parquet port):OrcFileFormatmixes inSupportsArchiveFormat, returnsarchiveEntryFilter = true(ORC part-files are often extensionless, so every entry is read), reportsisSplitable = falsefor an archive path, and inbuildReaderWithPartitionValuesdispatches an archive input toreadLocalizedEntries, which unpacks each entry to a temp file and runs the normal single-file reader over it.OrcUtilsroutes schema inference through the archive: the non-merge path samples the first entry (readArchiveSchemas(stopAtFirst = true), matching ORC's existing sample-one behavior, SPARK-11500), and themergeSchemaparallel path folds every entry (whole-archive-atomic on a corrupt entry). A corrupt archive surfaces the samecannotReadFooterForFileErrora corrupt loose file does.The shared test base is refactored so the localize-path tests (vectorized-reader read parity, abandoned-read/corrupt-archive temp-dir cleanup, extensionless entries,
mergeSchemafield union) live inArchiveReadSuiteBasebehindlocalizesEntries, keyed on newarchiveTempDirPrefix/vectorizedReaderConfKeyhooks, instead of being duplicated per random-access format.ParquetArchiveReadBaseis slimmed to set those hooks;OrcArchiveReadBasereuses them.Why are the changes needed?
ORC was the remaining columnar format without archive-read support; this brings it to parity with Parquet and the streaming formats, so users can read archived ORC datasets without unpacking them first. Folding the shared random-access tests into the base avoids duplicating them for every columnar format.
Does this PR introduce any user-facing change?
Yes. When
spark.sql.files.archive.reader.enabledis true (default false), the ORC data source reads supported archives as directories of their entries, for both scan and schema inference. With the flag off (the default) there is no behavior change.How was this patch tested?
New
OrcTarArchiveReadSuite,OrcZipArchiveReadSuite, andOrcSevenZArchiveReadSuiterun the sharedArchiveReadSuiteBasematrix over ORC (read parity with a directory, schema inference, vectorized on/off, corrupt/missing handling,mergeSchemaunion, temp-dir cleanup). The refactored localize-path tests continue to run for Parquet viaParquetArchiveReadBase.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code