Class ReadFromChangelogs
- All Implemented Interfaces:
Serializable,HasDisplayData
PTransform that processes batches of ChangelogScanTasks and routes them
accordingly:
- Records from Uni-directional batches are directly emitted, as INSERT or DELETE kind
- Records from Bi-directional batches are compared against the Primary Key overlap range:
- if outside the overlap, emit directly as INSERT or DELETE kind
- if inside the overlap, key by (snapshot seq#, pk) and route to downstream
CoGroupByKeyand final resolution byResolveChanges
We first key bi-directional rows by (snapshot sequence number, primary key) before sending to
CoGroupByKey to ensure they stay isolated from other PKs or snapshots. Inserts are routed
to
A ChangelogScanTask comes in three types:
- AddedRowsScanTask: Indicates records have been inserted by a new DataFile.
- DeletedRowsScanTask: Indicates records have been deleted using a DeleteFile.
- DeletedDataFileScanTask: Indicates a whole DataFile has been deleted.
Each of these types need to be processed differently. More details in CdcReadUtils.changelogRecordsForTask(org.apache.beam.sdk.io.iceberg.cdc.SerializableChangelogTask, org.apache.iceberg.Table, org.apache.beam.sdk.io.iceberg.IcebergScanConfig, boolean).
CDC metadata has two entry points in this transform. Row metadata columns are requested from
the Iceberg reader by CdcReadUtils and travel inside intermediate rows until final output
assembly. Snapshot metadata columns come from the ChangelogDescriptor / CdcRowDescriptor carried with each task or shuffled row, and _change_type comes from the
emitted change kind. Final user-visible rows are assembled by CdcOutputUtils.outputRow(java.util.List<java.lang.String>, org.apache.beam.sdk.schemas.Schema, org.apache.beam.sdk.io.iceberg.cdc.ChangelogDescriptor, org.apache.beam.sdk.values.ValueKind, org.apache.beam.sdk.values.Row),
which appends all requested metadata as top-level columns in the configured order.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints -
Method Summary
Modifier and TypeMethodDescriptionexpand(PCollectionTuple input) Override this method to specify how thisPTransformshould be expanded on the givenInputT.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
-
Method Details
-
expand
Description copied from class:PTransformOverride this method to specify how thisPTransformshould be expanded on the givenInputT.NOTE: This method should not be called directly. Instead apply the
PTransformshould be applied to theInputTusing theapplymethod.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expandin classPTransform<PCollectionTuple,ReadFromChangelogs.Output>
-