Skip to content

Commit f1d9c3e

Browse files
authored
docs: Document pipeline runner API protos (#39292)
* Document pipeline runner API protos Add documentation comments to previously undocumented messages and fields in the Beam Runner API pipeline model protos: beam_runner_api.proto: State specs (ReadModifyWrite, Bag, Combining, Map, Multimap, Set, TimerFamily), environment payloads (Docker, Process, External, AnyOf), artifact messages, triggers, RedistributePayload, IsBounded, LabelledPayload, and more. metrics.proto: MonitoringInfo, MonitoringInfoSpecs, labels, type URNs. schema.proto: Schema, Field, FieldType, all type variants, Row, FieldValue. external_transforms.proto: ManagedTransforms, Annotations. endpoints.proto: AuthenticationSpec. * Minor fixes Co-authored-by: Danny McCormick <dannymccormick@google.com>
1 parent da7693c commit f1d9c3e

5 files changed

Lines changed: 269 additions & 15 deletions

File tree

model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/beam_runner_api.proto

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,17 @@ message StateSpec {
586586
FunctionSpec protocol = 7;
587587
}
588588

589+
// Specification for a read-modify-write state cell, which holds a single value
590+
// per key and window. The value can be read, modified, and written back atomically.
589591
message ReadModifyWriteStateSpec {
592+
// (Required) The id of the Coder for the values stored in this state cell.
590593
string coder_id = 1;
591594
}
592595

596+
// Specification for a bag state cell, which holds an unordered collection of elements
597+
// per key and window. Elements can be appended and read as an iterable.
593598
message BagStateSpec {
599+
// (Required) The id of the Coder for elements stored in this bag.
594600
string element_coder_id = 1;
595601
}
596602

@@ -601,30 +607,57 @@ message OrderedListStateSpec {
601607
string element_coder_id = 1;
602608
}
603609

610+
// Specification for a combining state cell, which incrementally combines values
611+
// using a CombineFn. Rather than storing all input values, it stores a single
612+
// accumulator that is updated as new values arrive.
604613
message CombiningStateSpec {
614+
// (Required) The id of the Coder for the accumulator.
605615
string accumulator_coder_id = 1;
616+
// (Required) The FunctionSpec of the CombineFn used to combine values.
606617
FunctionSpec combine_fn = 2;
607618
}
608619

620+
// Specification for a map state cell, which holds a key-value mapping per key
621+
// and window. Keys and values can be read, written, and deleted individually.
622+
// Note: This is distinct from MultimapStateSpec in that MapState keys are unique.
623+
// In practice, Beam SDKs use Multimap state for both map and multimap semantics.
609624
message MapStateSpec {
625+
// (Required) The id of the Coder for map keys.
610626
string key_coder_id = 1;
627+
// (Required) The id of the Coder for map values.
611628
string value_coder_id = 2;
612629
}
613630

631+
// Specification for a multimap state cell, which holds a key-to-multiple-values
632+
// mapping per key and window. A single key can be associated with multiple values,
633+
// analogous to a multimap.
614634
message MultimapStateSpec {
635+
// (Required) The id of the Coder for map keys.
615636
string key_coder_id = 1;
637+
// (Required) The id of the Coder for map values.
616638
string value_coder_id = 2;
617639
}
618640

641+
// Specification for a set state cell, which holds an unordered collection of
642+
// unique elements per key and window. Elements can be added, removed, and checked
643+
// for existence.
619644
message SetStateSpec {
645+
// (Required) The id of the Coder for elements stored in this set.
620646
string element_coder_id = 1;
621647
}
622648

649+
// Specification for a timer family, which groups timers that share the same
650+
// time domain and encoding. Timer families allow timers to be managed together,
651+
// including batch processing of expired timers.
623652
message TimerFamilySpec {
653+
// (Required) The time domain for this timer family (event time or processing time).
624654
TimeDomain.Enum time_domain = 1;
655+
// (Required) The id of the Coder for timers in this family.
625656
string timer_family_coder_id = 2;
626657
}
627658

659+
// Indicates whether a PCollection is bounded (finite, known size) or unbounded (infinite, unknown size).
660+
// This affects how runners execute the pipeline and which features are available.
628661
message IsBounded {
629662
enum Enum {
630663
UNSPECIFIED = 0;
@@ -811,7 +844,13 @@ message GroupIntoBatchesPayload {
811844
int64 max_buffering_duration_millis = 2;
812845
}
813846

847+
// Payload for the RedistributeByKey and RedistributeArbitrarily composite transforms.
848+
// These transforms redistribute elements across workers, optionally allowing duplicates
849+
// to improve throughput at the cost of additional processing.
814850
message RedistributePayload {
851+
// (Optional) If true, the redistribution may produce duplicate elements.
852+
// This can improve performance by avoiding costly deduplication, but requires
853+
// downstream transforms to be tolerant of duplicates.
815854
bool allow_duplicates = 1;
816855
}
817856

@@ -1330,8 +1369,9 @@ message Trigger {
13301369
message Default {
13311370
}
13321371

1333-
// Ready whenever the requisite number of input elements have arrived
1372+
// Ready whenever the requisite number of input elements have arrived.
13341373
message ElementCount {
1374+
// (Required) The number of elements that must arrive before this trigger fires.
13351375
int32 element_count = 1;
13361376
}
13371377

@@ -1477,11 +1517,12 @@ message StandardArtifacts {
14771517
}
14781518
}
14791519

1520+
// Payload for a file-based artifact, referencing a locally-accessible file on disk.
14801521
message ArtifactFilePayload {
1481-
// a string for an artifact file path e.g. "/tmp/foo.jar"
1522+
// (Required) A file path for an artifact e.g. "/tmp/foo.jar"
14821523
string path = 1;
14831524

1484-
// The hex-encoded sha256 checksum of the artifact.
1525+
// (Optional) The hex-encoded sha256 checksum of the artifact.
14851526
string sha256 = 2;
14861527
}
14871528

@@ -1498,11 +1539,12 @@ message EmbeddedFilePayload {
14981539
bytes data = 1;
14991540
}
15001541

1542+
// Payload for a PyPI artifact, describing a Python package dependency.
15011543
message PyPIPayload {
1502-
// Pypi compatible artifact id e.g. "apache-beam"
1544+
// (Required) A PyPI-compatible artifact id e.g. "apache-beam"
15031545
string artifact_id = 1;
15041546

1505-
// Pypi compatible version string.
1547+
// (Required) A PyPI-compatible version string, e.g. "2.59.0"
15061548
string version = 2;
15071549
}
15081550

@@ -1515,29 +1557,40 @@ message MavenPayload {
15151557
string repository_url = 2;
15161558
}
15171559

1560+
// Payload for a deferred artifact, where the interpretation of the data is
1561+
// deferred to the creator. This allows custom artifact types not covered by
1562+
// the standard artifact types.
15181563
message DeferredArtifactPayload {
1519-
// A unique string identifier assigned by the creator of this payload. The creator may use this key to confirm
1564+
// (Required) A unique string identifier assigned by the creator of this payload. The creator may use this key to confirm
15201565
// whether they can parse the data.
15211566
string key = 1;
15221567

1523-
// Data for deferred artifacts. Interpretation of bytes is delegated to the creator of this payload.
1568+
// (Required) Data for deferred artifacts. Interpretation of bytes is delegated to the creator of this payload.
15241569
bytes data = 2;
15251570
}
15261571

1572+
// Payload for the staging_to role, used when an artifact needs to be staged
1573+
// to a particular location. The staged name is relative to the staging directory.
15271574
message ArtifactStagingToRolePayload {
1528-
// A generated staged name (relative path under staging directory).
1575+
// (Required) A generated staged name (relative path under staging directory).
15291576
string staged_name = 1;
15301577
}
15311578

1579+
// Full descriptor of an artifact, including its type and role.
1580+
// Used to describe dependencies of an Environment.
15321581
message ArtifactInformation {
1533-
// A URN that describes the type of artifact
1582+
// (Required) A URN that describes the type of artifact (e.g. file, URL, embedded, PyPI, Maven).
1583+
// See StandardArtifacts.Types for well-known URNs.
15341584
string type_urn = 1;
15351585

1586+
// (Optional) The payload for the artifact type, as determined by type_urn.
15361587
bytes type_payload = 2;
15371588

1538-
// A URN that describes the role of artifact
1589+
// (Required) A URN that describes the role of the artifact (e.g. staging_to, go_worker_binary).
1590+
// See StandardArtifacts.Roles for well-known URNs.
15391591
string role_urn = 3;
15401592

1593+
// (Optional) The payload for the artifact role, as determined by role_urn.
15411594
bytes role_payload = 4;
15421595
}
15431596

@@ -1598,24 +1651,41 @@ message StandardEnvironments {
15981651
}
15991652
}
16001653

1601-
// The payload of a Docker image
1654+
// Payload for a Docker container environment.
16021655
message DockerPayload {
1656+
// (Required) The Docker container image URL, e.g. "apache/beam_java_sdk:2.59.0"
16031657
string container_image = 1; // implicitly linux_amd64.
16041658
}
16051659

1660+
// Payload for a native process environment, where the SDK harness is launched as
1661+
// a subprocess directly on the worker machine (not inside a container).
16061662
message ProcessPayload {
1663+
// (Required) The operating system, e.g. "linux", "darwin".
16071664
string os = 1; // "linux", "darwin", ..
1665+
// (Required) The CPU architecture, e.g. "amd64", "arm64".
16081666
string arch = 2; // "amd64", ..
1667+
// (Required) The command to execute to start the SDK harness process.
16091668
string command = 3; // process to execute
1669+
// (Optional) Environment variables to set for the SDK harness process.
16101670
map<string, string> env = 4; // Environment variables
16111671
}
16121672

1673+
// Payload for an external process environment, where the SDK harness is managed
1674+
// by an external service rather than directly by the runner. The runner communicates
1675+
// with the external worker pool via the provided gRPC endpoint.
16131676
message ExternalPayload {
1677+
// (Required) The gRPC endpoint serving the BeamFnExternalWorkerPool API.
16141678
ApiServiceDescriptor endpoint = 1; // Serving BeamFnExternalWorkerPool API.
1679+
// (Optional) Arbitrary extra parameters to pass to the external worker pool.
16151680
map<string, string> params = 2; // Arbitrary extra parameters to pass
16161681
}
16171682

1683+
// Payload for an AnyOf environment, which presents a set of equivalent environments
1684+
// that a runner may choose from. Each alternative is fully specified with its own
1685+
// dependencies, capabilities, etc. This allows SDKs to express flexibility in
1686+
// execution environment while preserving compatibility across runners.
16181687
message AnyOfEnvironmentPayload {
1688+
// (Required) The list of fully-specified environments the runner may choose from.
16191689
// Each is fully contained (with their own dependencies, capabilities, etc.)
16201690
repeated Environment environments = 1;
16211691
}
@@ -1852,6 +1922,8 @@ message StandardDisplayData {
18521922
}
18531923
}
18541924

1925+
// A labelled display data payload, associating a human-readable label with a value.
1926+
// Used as the payload for the StandardDisplayData.LABELLED URN.
18551927
message LabelledPayload {
18561928
// (Required) A human readable label for the value.
18571929
string label = 1;

model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/endpoints.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ message ApiServiceDescriptor {
3939
AuthenticationSpec authentication = 2;
4040
}
4141

42+
// Describes the authentication mechanism for connecting to a Beam API endpoint.
43+
// Uses a URN-based approach to allow different authentication methods (e.g. OAuth2,
44+
// bearer tokens) to be specified in an extensible manner.
4245
message AuthenticationSpec {
4346
// (Required) A URN that describes the accompanying payload.
4447
// For any URN that is not recognized (by whomever is inspecting

model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/external_transforms.proto

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,49 @@ message ExpansionMethods {
6060
}
6161

6262
// Defines the URNs for managed transforms.
63+
// Managed transforms are high-level, pre-configured transforms that map to
64+
// specific SchemaTransform implementations. They provide a way to
65+
// to use common I/O patterns without worrying about Beam version.
66+
// See https://beam.apache.org/documentation/io/managed-io/
6367
message ManagedTransforms {
6468
enum Urns {
69+
// Reads from an Iceberg table.
6570
ICEBERG_READ = 0 [(org.apache.beam.model.pipeline.v1.beam_urn) =
6671
"beam:schematransform:org.apache.beam:iceberg_read:v1"];
72+
// Writes to an Iceberg table.
6773
ICEBERG_WRITE = 1 [(org.apache.beam.model.pipeline.v1.beam_urn) =
6874
"beam:schematransform:org.apache.beam:iceberg_write:v1"];
75+
// Reads from a Kafka topic.
6976
KAFKA_READ = 2 [(org.apache.beam.model.pipeline.v1.beam_urn) =
7077
"beam:schematransform:org.apache.beam:kafka_read:v1"];
78+
// Writes to a Kafka topic.
7179
KAFKA_WRITE = 3 [(org.apache.beam.model.pipeline.v1.beam_urn) =
7280
"beam:schematransform:org.apache.beam:kafka_write:v1"];
81+
// Reads from BigQuery using the Storage API.
7382
BIGQUERY_READ = 4 [(org.apache.beam.model.pipeline.v1.beam_urn) =
7483
"beam:schematransform:org.apache.beam:bigquery_storage_read:v1"];
84+
// Writes to BigQuery.
7585
BIGQUERY_WRITE = 5 [(org.apache.beam.model.pipeline.v1.beam_urn) =
7686
"beam:schematransform:org.apache.beam:bigquery_write:v1"];
87+
// Reads from Iceberg in CDC (Change Data Capture) mode.
7788
ICEBERG_CDC_READ = 6 [(org.apache.beam.model.pipeline.v1.beam_urn) =
7889
"beam:schematransform:org.apache.beam:iceberg_cdc_read:v1"];
90+
// Reads from a PostgreSQL database.
7991
POSTGRES_READ = 7 [(org.apache.beam.model.pipeline.v1.beam_urn) =
8092
"beam:schematransform:org.apache.beam:postgres_read:v1"];
93+
// Writes to a PostgreSQL database.
8194
POSTGRES_WRITE = 8 [(org.apache.beam.model.pipeline.v1.beam_urn) =
8295
"beam:schematransform:org.apache.beam:postgres_write:v1"];
96+
// Reads from a MySQL database.
8397
MYSQL_READ = 9 [(org.apache.beam.model.pipeline.v1.beam_urn) =
8498
"beam:schematransform:org.apache.beam:mysql_read:v1"];
99+
// Writes to a MySQL database.
85100
MYSQL_WRITE = 10 [(org.apache.beam.model.pipeline.v1.beam_urn) =
86101
"beam:schematransform:org.apache.beam:mysql_write:v1"];
102+
// Reads from a SQL Server database.
87103
SQL_SERVER_READ = 11 [(org.apache.beam.model.pipeline.v1.beam_urn) =
88104
"beam:schematransform:org.apache.beam:sql_server_read:v1"];
105+
// Writes to a SQL Server database.
89106
SQL_SERVER_WRITE = 12 [(org.apache.beam.model.pipeline.v1.beam_urn) =
90107
"beam:schematransform:org.apache.beam:sql_server_write:v1"];
91108
DELTA_LAKE_READ = 13 [(org.apache.beam.model.pipeline.v1.beam_urn) =
@@ -145,6 +162,9 @@ message BuilderMethod {
145162
bytes payload = 3;
146163
}
147164

165+
// Defines annotation keys used to attach metadata to transforms in the
166+
// portable pipeline representation. These annotations allow SDKs to
167+
// recover configuration information that was used to construct a transform.
148168
message Annotations {
149169
enum Enum {
150170
// The annotation key for the encoded configuration Row used to build a transform

0 commit comments

Comments
 (0)