Skip to content

AddFiles: read side of the schema pre-pass - #39933

Open
claudevdm wants to merge 1 commit into
apache:masterfrom
claudevdm:read-footer-schema
Open

AddFiles: read side of the schema pre-pass #39933
claudevdm wants to merge 1 commit into
apache:masterfrom
claudevdm:read-footer-schema

Conversation

@claudevdm

Copy link
Copy Markdown
Collaborator

ReadFooterSchema, FileScemas.canonical, CollectDistinctSchemas)

New, not yet wired code that turns a PCollection of file paths into the list of distinct schemas those files carry, with file counts. The pre-pass that will use it exists because manifest entries are immutable: a file registered before the table knows one of its columns never gets stats for that column, so the table schema has to be brought up to date before any file is registered, and that requires looking at every footer first.

ReadFooterSchema (DoFn<String, String>) reads each Parquet footer on the BoundedAsyncTasks pool and emits the file's canonical schema as JSON. Non-Parquet paths and unknown extensions contribute nothing; a footer that cannot be read or converted is logged and counted (numFooterReadErrors) but never fails the pipeline: the per-file registration step reports such files individually later.

FileSchemas.canonical sorts struct fields by name at every level and renumbers ids in deterministic order.
The ids are positional and never consumed downstream: the commit side reconciles columns by name (unionByNameWith).

CollectDistinctSchemas is a CombineFn over the canonical JSON strings (Map<String, Long> accumulator) producing List<KV<String, Long>> ordered most common first, ties broken by the JSON text for determinism. The most common schema goes first because the commit side uses it as the seed when the table does not exist yet.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

…emas.canonical, CollectDistinctSchemas)

New, not yet wired code that turns a PCollection of file paths into the
list of distinct schemas those files carry, with file counts. The
pre-pass that will use it exists because manifest entries are immutable:
a file registered before the table knows one of its columns never gets
stats for that column, so the table schema has to be brought up to date
before any file is registered, and that requires looking at every
footer first.

ReadFooterSchema (DoFn<String, String>) reads each Parquet footer on the
BoundedAsyncTasks pool and emits the file's canonical schema as JSON.
Non-Parquet paths and unknown extensions contribute nothing; a footer
that cannot be read or converted is logged and counted
(numFooterReadErrors) but never fails the pipeline: the per-file
registration step reports such files individually later.

FileSchemas.canonical sorts struct fields by name at every level and
renumbers ids in deterministic order.
The ids are positional and never consumed downstream: the commit side
reconciles columns by name (unionByNameWith).

CollectDistinctSchemas is a CombineFn over the canonical JSON strings
(Map<String, Long> accumulator) producing List<KV<String, Long>> ordered
most common first, ties broken by the JSON text for determinism.
The most common schema goes first because the commit side uses it as the
seed when the table does not exist yet.
@claudevdm
claudevdm marked this pull request as ready for review August 31, 2026 13:15
@claudevdm
claudevdm requested a review from ahmedabu98 August 31, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant