Skip to content

[SPARK-58605][SQL] Verify parent-archive _metadata for archive reads - #57805

Closed
akshatshenoi-db wants to merge 1 commit into
apache:masterfrom
akshatshenoi-db:archive-metadata
Closed

[SPARK-58605][SQL] Verify parent-archive _metadata for archive reads#57805
akshatshenoi-db wants to merge 1 commit into
apache:masterfrom
akshatshenoi-db:archive-metadata

Conversation

@akshatshenoi-db

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Adds tests asserting that reading an archive exposes the parent archive file's values in the _metadata column (file_path, file_name, file_size, file_modification_time, file_block_start, file_block_length).

An archive is read as a single non-splittable PartitionedFile, so the generic FileFormat metadata extractors already produce the parent archive's values (file_block_start = 0, file_block_length = file_size = the archive's size on disk). This PR is therefore test-only: no production change was needed. The tests pin the behavior so it cannot silently regress.

Inner-file _metadata is explicitly a non-goal: because the archive is a single split, the _metadata mechanism operates at PartitionedFile granularity and cannot attribute a row to its originating inner entry.

This follows the archive-reader series: SPARK-57135 / SPARK-57321 (CSV), SPARK-57419 (JSON), SPARK-57478 (text), SPARK-57479 (XML), SPARK-57481 (Avro), SPARK-58382 (binaryFile), SPARK-57705 (zip), SPARK-58246 (7z).

Why are the changes needed?

The parent-archive _metadata contract was entirely untested. A future change to file splitting or to the metadata extractors could regress it unnoticed, and users reading archives rely on _metadata to identify the source archive file.

Does this PR introduce any user-facing change?

No. Test-only; archive reading remains gated by spark.sql.files.archive.reader.enabled (default false).

How was this patch tested?

A new shared test in ArchiveReadSuiteBase, which runs for every format x container suite (csv/json/xml/avro x tar/zip/7z), asserting every row of a multi-entry archive carries the same parent-archive values, with file_block_start = 0 and file_block_length = file_size = the archive's size.

Plus the parallel test in TextArchiveReadBase and BinaryFileArchiveReadBase, which do not extend ArchiveReadSuiteBase (their row shapes differ). For binaryFile with wholeFile=false the test additionally pins that _metadata stays parent-only even though the path/length data columns are sourced per entry.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

### What changes were proposed in this pull request?

Adds tests asserting that reading an archive exposes the parent archive file's
values in the `_metadata` column (`file_path`, `file_name`, `file_size`,
`file_modification_time`, `file_block_start`, `file_block_length`).

An archive is read as a single non-splittable `PartitionedFile`, so the generic
`FileFormat` metadata extractors already produce the parent archive's values
(`file_block_start` = 0, `file_block_length` = `file_size` = the archive's
size). This is test-only: no production change is needed, and the tests pin the
behavior so it cannot silently regress.

Inner-file `_metadata` is explicitly a non-goal: because the archive is a single
split, the `_metadata` mechanism cannot attribute a row to its originating
inner entry.

### Why are the changes needed?

The parent-archive `_metadata` contract was untested, so a future change to
splitting or to the metadata extractors could regress it unnoticed.

### Does this PR introduce any user-facing change?

No. Test-only; archive reading remains gated by
`spark.sql.files.archive.reader.enabled` (default false).

### How was this patch tested?

New shared test in `ArchiveReadSuiteBase`, which runs for every
format x container suite (csv/json/xml/avro x tar/zip/7z), plus the parallel
test in `TextArchiveReadBase` and `BinaryFileArchiveReadBase` (which do not
extend `ArchiveReadSuiteBase`). For binaryFile with `wholeFile=false` the test
also pins that `_metadata` stays parent-only even though the `path`/`length`
data columns are per entry.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code
@uros-b
uros-b requested a review from cloud-fan August 6, 2026 08:53
@uros-b

uros-b commented Aug 6, 2026

Copy link
Copy Markdown
Member

cc @cloud-fan who has more context on archive format

@cloud-fan cloud-fan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 blocking, 0 non-blocking, 0 nits.
The tests accurately capture the current parent-archive metadata contract across the three suite hierarchies; no code findings were identified.

Verification

I traced the selected fields to FileFormat.BASE_METADATA_EXTRACTORS, where path, name, size, split start, split length, and modification time are derived from the enclosing PartitionedFile. I also verified that archive reads are forced to one split and that text and binary readers stream entries through that parent file. No tests were run as part of this review.

PR metadata suggestions

  • Correct the test-matrix description: ArchiveReadSuiteBase also has Parquet and ORC suites, so the new shared test is not limited to csv/json/xml/avro.

@cloud-fan cloud-fan closed this in cc7fac3 Aug 6, 2026
cloud-fan pushed a commit that referenced this pull request Aug 6, 2026
### What changes were proposed in this pull request?

Adds tests asserting that reading an archive exposes the **parent archive file's** values in the `_metadata` column (`file_path`, `file_name`, `file_size`, `file_modification_time`, `file_block_start`, `file_block_length`).

An archive is read as a single non-splittable `PartitionedFile`, so the generic `FileFormat` metadata extractors already produce the parent archive's values (`file_block_start` = 0, `file_block_length` = `file_size` = the archive's size on disk). This PR is therefore **test-only**: no production change was needed. The tests pin the behavior so it cannot silently regress.

Inner-file `_metadata` is explicitly a **non-goal**: because the archive is a single split, the `_metadata` mechanism operates at `PartitionedFile` granularity and cannot attribute a row to its originating inner entry.

This follows the archive-reader series: SPARK-57135 / SPARK-57321 (CSV), SPARK-57419 (JSON), SPARK-57478 (text), SPARK-57479 (XML), SPARK-57481 (Avro), SPARK-58382 (binaryFile), SPARK-57705 (zip), SPARK-58246 (7z).

### Why are the changes needed?

The parent-archive `_metadata` contract was entirely untested. A future change to file splitting or to the metadata extractors could regress it unnoticed, and users reading archives rely on `_metadata` to identify the source archive file.

### Does this PR introduce any user-facing change?

No. Test-only; archive reading remains gated by `spark.sql.files.archive.reader.enabled` (default false).

### How was this patch tested?

A new shared test in `ArchiveReadSuiteBase`, which runs for every format x container suite (csv/json/xml/avro x tar/zip/7z), asserting every row of a multi-entry archive carries the same parent-archive values, with `file_block_start = 0` and `file_block_length = file_size = ` the archive's size.

Plus the parallel test in `TextArchiveReadBase` and `BinaryFileArchiveReadBase`, which do not extend `ArchiveReadSuiteBase` (their row shapes differ). For binaryFile with `wholeFile=false` the test additionally pins that `_metadata` stays parent-only even though the `path`/`length` **data** columns are sourced per entry.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

Closes #57805 from akshatshenoi-db/archive-metadata.

Authored-by: akshatshenoi-db <akshat.shenoi@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit cc7fac3)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan pushed a commit that referenced this pull request Aug 6, 2026
### What changes were proposed in this pull request?

Adds tests asserting that reading an archive exposes the **parent archive file's** values in the `_metadata` column (`file_path`, `file_name`, `file_size`, `file_modification_time`, `file_block_start`, `file_block_length`).

An archive is read as a single non-splittable `PartitionedFile`, so the generic `FileFormat` metadata extractors already produce the parent archive's values (`file_block_start` = 0, `file_block_length` = `file_size` = the archive's size on disk). This PR is therefore **test-only**: no production change was needed. The tests pin the behavior so it cannot silently regress.

Inner-file `_metadata` is explicitly a **non-goal**: because the archive is a single split, the `_metadata` mechanism operates at `PartitionedFile` granularity and cannot attribute a row to its originating inner entry.

This follows the archive-reader series: SPARK-57135 / SPARK-57321 (CSV), SPARK-57419 (JSON), SPARK-57478 (text), SPARK-57479 (XML), SPARK-57481 (Avro), SPARK-58382 (binaryFile), SPARK-57705 (zip), SPARK-58246 (7z).

### Why are the changes needed?

The parent-archive `_metadata` contract was entirely untested. A future change to file splitting or to the metadata extractors could regress it unnoticed, and users reading archives rely on `_metadata` to identify the source archive file.

### Does this PR introduce any user-facing change?

No. Test-only; archive reading remains gated by `spark.sql.files.archive.reader.enabled` (default false).

### How was this patch tested?

A new shared test in `ArchiveReadSuiteBase`, which runs for every format x container suite (csv/json/xml/avro x tar/zip/7z), asserting every row of a multi-entry archive carries the same parent-archive values, with `file_block_start = 0` and `file_block_length = file_size = ` the archive's size.

Plus the parallel test in `TextArchiveReadBase` and `BinaryFileArchiveReadBase`, which do not extend `ArchiveReadSuiteBase` (their row shapes differ). For binaryFile with `wholeFile=false` the test additionally pins that `_metadata` stays parent-only even though the `path`/`length` **data** columns are sourced per entry.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

Closes #57805 from akshatshenoi-db/archive-metadata.

Authored-by: akshatshenoi-db <akshat.shenoi@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit cc7fac3)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@cloud-fan

Copy link
Copy Markdown
Contributor

Merge Summary:

Posted by merge_spark_pr.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants