Skip to content

feat(spanner): Add directed read options support for Spanner change stream templates - #4214

Open
ath-08 wants to merge 8 commits into
GoogleCloudPlatform:mainfrom
ath-08:spanner-change-streams-directed-reads
Open

ath-08 wants to merge 8 commits into
GoogleCloudPlatform:mainfrom
ath-08:spanner-change-streams-directed-reads

Conversation

@ath-08

@ath-08 ath-08 commented Sep 2, 2026

Copy link
Copy Markdown
  • Bump Beam version to 2.76.0 to support DirectedReadOptions on SpannerIO.ReadChangeStream
  • Add spannerDirectedReadOptions pipeline option to Spanner Change Streams to BigQuery, GCS, and Pub/Sub templates
  • Pass directed read options to SpannerIO.readChangeStream() in each template
  • Add unit tests validating directed read options configuration

@ath-08
ath-08 requested a review from a team as a code owner September 2, 2026 21:15
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for Cloud Spanner directed read options within the Spanner Change Streams data pipeline templates. By upgrading the underlying Apache Beam dependency and exposing a new pipeline parameter, users can now specify directed read configurations to optimize Spanner read operations. The changes ensure that these options are correctly propagated to the SpannerIO read stream across all supported output destinations.

Highlights

  • Dependency Update: Bumped Apache Beam version to 2.76.0 to enable support for DirectedReadOptions in SpannerIO.
  • New Pipeline Option: Added 'spannerDirectedReadOptions' as a configurable parameter for Spanner Change Streams to BigQuery, GCS, and Pub/Sub templates.
  • Template Integration: Updated template logic to pass the directed read options configuration to SpannerIO.readChangeStream().
  • Testing: Added unit tests to verify the correct configuration and application of directed read options across templates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates Apache Beam dependencies to version 2.76.0 and introduces support for Cloud Spanner directed read options across several Spanner change streams templates (BigQuery, GCS, and Pub/Sub). It adds the spannerDirectedReadOptions template parameter and updates the respective templates to apply these options when reading from Spanner change streams. The review feedback points out that the unit test in SpannerChangeStreamsToGcsTest.java bypasses the template execution path by manually constructing the pipeline instead of using the run(options) method, and suggests refactoring the test to ensure the template code path is properly verified.

Comment thread v2/googlecloud-to-googlecloud/README_Spanner_Change_Streams_to_PubSub.md Outdated

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

Overall very good and the one pager is really helpful.

@ath-08
ath-08 force-pushed the spanner-change-streams-directed-reads branch from e573522 to c138a1d Compare September 14, 2026 20:59
@ath-08
ath-08 requested a review from tianz101 September 14, 2026 21:03
tianz101
tianz101 previously approved these changes Sep 14, 2026
@chamikaramj chamikaramj added the improvement Making existing code better label Sep 17, 2026

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

Thanks!

Comment thread pom.xml
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.34%. Comparing base (6e68e20) to head (5a2586f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...leport/v2/templates/SpannerChangeStreamsToGcs.java 0.00% 2 Missing ⚠️
...ort/v2/templates/SpannerChangeStreamsToPubSub.java 0.00% 2 Missing ⚠️
...eamstobigquery/SpannerChangeStreamsToBigQuery.java 0.00% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4214      +/-   ##
============================================
- Coverage     56.35%   56.34%   -0.02%     
+ Complexity     7858     7402     -456     
============================================
  Files          1154     1154              
  Lines         73194    73197       +3     
  Branches       8580     8580              
============================================
- Hits          41252    41243       -9     
- Misses        29158    29167       +9     
- Partials       2784     2787       +3     
Components Coverage Δ
spanner-templates 84.47% <ø> (-0.01%) ⬇️
spanner-import-export 69.03% <ø> (-0.03%) ⬇️
spanner-live-forward-migration 88.96% <ø> (-0.02%) ⬇️
spanner-live-reverse-replication 80.85% <ø> (-0.02%) ⬇️
spanner-bulk-migration 88.99% <ø> (-0.01%) ⬇️
gcs-spanner-dv 88.08% <ø> (-0.02%) ⬇️
Files with missing lines Coverage Δ
...leport/v2/templates/SpannerChangeStreamsToGcs.java 0.00% <0.00%> (ø)
...ort/v2/templates/SpannerChangeStreamsToPubSub.java 0.00% <0.00%> (ø)
...eamstobigquery/SpannerChangeStreamsToBigQuery.java 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Atharva Moroney added 7 commits September 17, 2026 17:51
…tream templates

- Bump Beam version to 2.76.0 to support DirectedReadOptions on SpannerIO.ReadChangeStream
- Add spannerDirectedReadOptions pipeline option to Spanner Change Streams to BigQuery, GCS, and Pub/Sub templates
- Pass directed read options to SpannerIO.readChangeStream() in each template
- Add unit tests validating directed read options configuration
@ath-08
ath-08 force-pushed the spanner-change-streams-directed-reads branch from c138a1d to c92c423 Compare September 18, 2026 01:13
@ath-08
ath-08 requested a review from chamikaramj September 18, 2026 01:22
chamikaramj
chamikaramj previously approved these changes Sep 18, 2026

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

I can merge when tests pass.

- Keep directed read unit tests offline and fast: assert that the option
  value is parsed onto the SpannerConfig used by SpannerIO instead of
  building a pipeline against a real Cloud Spanner instance.
- Add coverage for unset and malformed directed read option values.
- Put the Pub/Sub option tests in their own class, since
  SpannerChangeStreamsToPubSubTest declares a TestPubsubSignal rule that
  creates real Pub/Sub topics before every test and therefore only runs
  as an integration test.
- Drop the Pub/Sub and BigQuery directed read integration tests; option
  validation is covered by unit tests and the Cloud Storage IT already
  validates real pipeline output.
- Revert unrelated reformatting of the template descriptions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Making existing code better size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants