AddFiles: SchemaDelta classifies what a file schema needs from the table (#40062)

* AddFiles: SchemaDelta classifies what a file schema needs from the table

The classifier behind the options. Iceberg's unionByNameWith has no
knobs: it adds, relaxes and promotes in one go, or throws. To honour
ALLOW_FIELD_ADDITION / ALLOW_FIELD_RELAXATION / ALLOW_TYPE_PROMOTION
separately, SchemaDelta.classify(table, fileSchema) applies the union
on a throwaway UpdateSchema (apply(), never commit()), diffs the result
against the current table schema, and labels every change:

- FIELD_ADDITION: a field id present only after the union.
- FIELD_RELAXATION: required before, optional after; or a required
  table column with no counterpart in the file at all (see below).
- TYPE_PROMOTION: same id, wider primitive type after.
- CONFLICT: anything else. The union throwing (ValidationException or
  IllegalArgumentException, e.g. int column vs string file column, a
  dotted or empty file column name), a field removed by the union
  (cannot happen with unionByName but is refused rather than trusted),
  a struct where a primitive was, a doc string or default changing, a
  promotion Iceberg would not allow (TypeUtil.isPromotionAllowed guard,
  so a bad union result is never staged as a "promotion").

The diff is keyed by field id and walks fields attribute by attribute
(name, optionality, type kind, doc, defaults), so an attribute the union
silently changes is reported rather than committed unnoticed. Changes
are listed in a deterministic order (unquoted path) with quoted names in
messages so a reviewer can find them in the schema.

Absence rule: a required table column that the file lacks is a
FIELD_RELAXATION, not a pass. Registering such a file would put nulls
in a required column for every reader; the fix is to relax the column
explicitly (the commit side stages makeColumnOptional for exactly the
paths absentRequiredPaths() reports). The walk descends through structs
whose parent is present, through list elements and map values (paths
use "element" and "value", which makeColumnOptional accepts); an absent
struct is itself the relaxation, its children are not listed
separately; map keys are required by definition and skipped.

Pins: Change.allowedBy(config) refuses a relaxation of a pinned path
even when ALLOW_FIELD_RELAXATION is set, and disallowedReason(config)
names it, so "id is pinned" shows up as the reason rather than a
generic "relaxation not allowed".

* move pins to class

* pins

* docstring

* Fix docstring

* tests

* split file

* split

* map keys

* track test
7 files changed
tree: 3670dea17f5e07e5963c44c3600e7044d463e933
  1. .agent/
  2. .gemini/
  3. .github/
  4. .test-infra/
  5. buildSrc/
  6. contributor-docs/
  7. dev-support/
  8. examples/
  9. gradle/
  10. infra/
  11. it/
  12. learning/
  13. model/
  14. playground/
  15. plugins/
  16. release/
  17. runners/
  18. scripts/
  19. sdks/
  20. vendor/
  21. website/
  22. .asf.yaml
  23. .editorconfig
  24. .gitattributes
  25. .gitignore
  26. .gitmodules
  27. .mailmap
  28. .pre-commit-config.yaml
  29. .yamllint.yml
  30. assembly.xml
  31. build.gradle.kts
  32. CHANGES.md
  33. CI.md
  34. CONTRIBUTING.md
  35. gradle.properties
  36. gradlew
  37. gradlew.bat
  38. LICENCE.cloudpickle
  39. LICENSE
  40. LICENSE.python
  41. local-env-setup.sh
  42. NOTICE
  43. README.md
  44. settings.gradle.kts
  45. start-build-env.sh
README.md

Apache Beam

Apache Beam is a unified model for defining both batch and streaming data-parallel processing pipelines, as well as a set of language-specific SDKs for constructing pipelines and Runners for executing them on distributed processing backends, including Apache Flink, Apache Spark, Google Cloud Dataflow, and Hazelcast Jet.

πŸš€ Quick Start (Beginner Friendly)

If you're new to Apache Beam, start here:

  1. Choose a language:

  2. Run your first example:

    • Minimal WordCount example (available in this repository)
  3. Understand core concepts:

    • PCollection
    • PTransform
    • Pipeline

Status

Maven Central PyPI version Go version Python coverage Build python source distribution and wheels Python tests Java tests Go tests

Overview

Beam provides a general approach to expressing embarrassingly parallel data processing pipelines and supports three categories of users, each of which have relatively disparate backgrounds and needs.

  1. End Users: Writing pipelines with an existing SDK, running it on an existing runner. These users want to focus on writing their application logic and have everything else just work.
  2. SDK Writers: Developing a Beam SDK targeted at a specific user community (Java, Python, Scala, Go, R, graphical, etc). These users are language geeks and would prefer to be shielded from all the details of various runners and their implementations.
  3. Runner Writers: Have an execution environment for distributed processing and would like to support programs written against the Beam Model. Would prefer to be shielded from details of multiple SDKs.

The Beam Model

The model behind Beam evolved from several internal Google data processing projects, including MapReduce, FlumeJava, and Millwheel. This model was originally known as the β€œDataflow Model”.

To learn more about the Beam Model (though still under the original name of Dataflow), see the World Beyond Batch: Streaming 101 and Streaming 102 posts on O’Reilly’s Radar site, and the VLDB 2015 paper.

The key concepts in the Beam programming model are:

  • PCollection: represents a collection of data, which could be bounded or unbounded in size.
  • PTransform: represents a computation that transforms input PCollections into output PCollections.
  • Pipeline: manages a directed acyclic graph of PTransforms and PCollections that is ready for execution.
  • PipelineRunner: specifies where and how the pipeline should execute.

SDKs

Beam supports multiple language-specific SDKs for writing pipelines against the Beam Model.

Currently, this repository contains SDKs for Java, Python and Go.

Have ideas for new SDKs or DSLs? See the sdk-ideas label.

Specific SDK Readmes

Runners

Beam supports executing programs on multiple distributed processing backends through PipelineRunners. Currently, the following PipelineRunners are available:

  • The DirectRunner runs the pipeline on your local machine.
  • The PrismRunner runs the pipeline on your local machine using Beam Portability.
  • The DataflowRunner submits the pipeline to the Google Cloud Dataflow.
  • The FlinkRunner runs the pipeline on an Apache Flink cluster. The code has been donated from dataArtisans/flink-dataflow and is now part of Beam.
  • The SparkRunner runs the pipeline on an Apache Spark cluster.
  • The JetRunner runs the pipeline on a Hazelcast Jet cluster. The code has been donated from hazelcast/hazelcast-jet and is now part of Beam.
  • The Twister2Runner runs the pipeline on a Twister2 cluster. The code has been donated from DSC-SPIDAL/twister2 and is now part of Beam.

Have ideas for new Runners? See the runner-ideas label.

Instructions for building and testing Beam itself are in the contribution guide.

πŸ“š Learn More

Here are some resources actively maintained by the Beam community to help you get started:

Contact Us

To get involved with Apache Beam: