Skip to content

Add Bigtable CDC YAML SchemaTransform - #40261

Open
Amar3tto wants to merge 8 commits into
masterfrom
bigtable-cdc-yaml
Open

Amar3tto wants to merge 8 commits into
masterfrom
bigtable-cdc-yaml

Conversation

@Amar3tto

@Amar3tto Amar3tto commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Adds YAML support for reading Google Cloud Bigtable change streams.

This PR:

  • adds a Bigtable CDC SchemaTransform provider
  • converts ChangeStreamMutation records to Beam Rows
  • supports SetCell, DeleteCells, DeleteFamily, AddToCell, and MergeToCell entries
  • registers ReadFromBigtableCDC in standard_io.yaml
  • adds unit tests for configuration and mutation entry conversion

Tested with:

./gradlew :sdks:java:io:google-cloud-platform:test \
  --tests org.apache.beam.sdk.io.gcp.bigtable.changestreams.BigtableChangeStreamReadSchemaTransformProviderTest

Successful run: https://github.com/apache/beam/actions/runs/35729484761


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.

@Amar3tto Amar3tto changed the title Bigtable CDC yaml Add Bigtable CDC YAML SchemaTransform Sep 24, 2026
@Amar3tto
Amar3tto requested a review from Abacn September 24, 2026 12:49
@Amar3tto
Amar3tto marked this pull request as ready for review October 6, 2026 08:04
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @Abacn

@damccorm

damccorm commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Load balancing out some reviews.

R: @derrickaw

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a missing integration yaml test that uses these changes?


static final Schema CHANGE_STREAM_MUTATION_SCHEMA =
Schema.builder()
.addByteArrayField("row_key")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets use "row" to match bigtablereadschematransformprovider

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.

should be "key" right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed to "key" as in the BigtableReadSchemaTransformProvider

Schema.builder()
.addStringField("type")
.addStringField("family_name")
.addNullableByteArrayField("qualifier")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets use "column_qualifier" to match bigtablereadschematransformprovider

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed


@Override
public String description() {
return "Reads change stream records from a Google Cloud Bigtable table.";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you provide an example usage? thanks

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines +263 to +268
.addValue(new Instant(mutation.getCommitTime().toEpochMilli()))
.addValue(mutation.getTieBreaker())
.addValue(mutation.getToken())
.addValue(new Instant(mutation.getEstimatedLowWatermarkTime().toEpochMilli()))
.addValue(entries)
.build();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we use milliseconds. In the regular bigtablereadschematransformprovider, it uses micro

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These fields are Beam DATETIMEs, so they are represented as Joda Instant and use millisecond precision. The regular Bigtable provider uses microseconds for cell timestamps because those are exposed as raw INT64 fields (timestamp_micros). I’d prefer to keep commit_timestamp and estimated_low_watermark as typed timestamps rather than numeric micros.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we add a mutationToRow test?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a mutationToRow test covering the top-level mutation fields and nested entries.

@derrickaw

Copy link
Copy Markdown
Collaborator

R: @ahmedabu98, can you take a quick peek at this to see if anything else is missing? Thanks

@ahmedabu98 ahmedabu98 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.

Looks good from a skim, just consider adding a flattened output option.

Also please add a YAML IT

.addNullableRowField("value_input", VALUE_SCHEMA)
.build();

static final Schema CHANGE_STREAM_MUTATION_SCHEMA =

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.

This output schema looks complex, which will be noticed when using it with YAML.

In the regular BigtableReadSchemaTransformProvider, we added an option to use a flattened schema (one output per entry, instead of per mutation). Consider doing something similar here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@ahmedabu98

Copy link
Copy Markdown
Contributor

cc @mutianf might be relevant for you

@Amar3tto

Copy link
Copy Markdown
Collaborator Author

please add a YAML IT

I tried adding a Bigtable CDC YAML IT using a temporary change-stream-enabled table and a bounded end time, but the pipeline consistently times out in the YAML Direct/FnApi integration-test harness.

Do you have a recommendation for how this integration test should be structured for a streaming CDC source? ReadFromSpannerCDC seems to have a similar setup, but I couldn't find a YAML IT for it either.

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.

4 participants