Skip to content

fix(datastream-to-bigquery): Added support to read SQLServer Primary keys from replication_index to support Merge operation (Issue #3805)#3806

Open
sandesh-jagdale-tp wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
sandesh-jagdale-tp:main
Open

fix(datastream-to-bigquery): Added support to read SQLServer Primary keys from replication_index to support Merge operation (Issue #3805)#3806
sandesh-jagdale-tp wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
sandesh-jagdale-tp:main

Conversation

@sandesh-jagdale-tp
Copy link
Copy Markdown

This is to address the correct reading of SQL Server primary keys from "replication_index" metadata field, if the primary key is not found in the default metadata field "primary_keys".

This is to address the issue reported in the bug - #3805

…Keys from replication-index to resolve merge operation in datastream-to-bigquery v2 dataflow template
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 13, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Copy Markdown

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 a fallback mechanism for identifying primary keys in Datastream records. By checking the 'replication_index' metadata field when 'primary_keys' is unavailable, the system now correctly supports SQL Server CDC sources, enabling proper Merge operations in BigQuery.

Highlights

  • Primary Key Resolution: Updated the primary key extraction logic to prioritize the 'primary_keys' field while falling back to 'replication_index' for SQL Server sources.
  • Enhanced Test Coverage: Added comprehensive unit tests to verify the fallback mechanism and ensure correct behavior when both fields are present or absent.
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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

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 introduces a fallback mechanism for retrieving primary keys from Datastream metadata, specifically adding support for 'replication_index' when 'primary_keys' is absent. The changes update both 'FormatDatastreamJsonToJson' and 'FormatDatastreamRecordToJson' classes and include comprehensive unit tests to verify the new logic. The review identified a potential NullPointerException risk and performance concerns in 'FormatDatastreamRecordToJson', as well as a need to handle explicitly null JSON nodes in 'FormatDatastreamJsonToJson' to ensure the fallback logic functions correctly.

… in the pull reuest for adding support to read SQLServer Primary Keys from replication-index
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.65%. Comparing base (0025d7e) to head (0f8e7c8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...tream/transforms/FormatDatastreamRecordToJson.java 62.50% 0 Missing and 3 partials ⚠️
...astream/transforms/FormatDatastreamJsonToJson.java 71.42% 0 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (66.66%) 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    #3806      +/-   ##
============================================
+ Coverage     53.62%   53.65%   +0.02%     
- Complexity     6323     6736     +413     
============================================
  Files          1087     1087              
  Lines         66762    66772      +10     
  Branches       7476     7481       +5     
============================================
+ Hits          35801    35826      +25     
+ Misses        28534    28518      -16     
- Partials       2427     2428       +1     
Components Coverage Δ
spanner-templates 72.83% <ø> (+0.03%) ⬆️
spanner-import-export 68.64% <ø> (+0.11%) ⬆️
spanner-live-forward-migration 80.93% <ø> (-0.02%) ⬇️
spanner-live-reverse-replication 77.08% <ø> (-0.02%) ⬇️
spanner-bulk-migration 91.10% <ø> (-0.01%) ⬇️
gcs-spanner-dv 85.74% <ø> (-0.02%) ⬇️
Files with missing lines Coverage Δ
...astream/transforms/FormatDatastreamJsonToJson.java 57.35% <71.42%> (+1.96%) ⬆️
...tream/transforms/FormatDatastreamRecordToJson.java 53.10% <62.50%> (+1.67%) ⬆️

... and 7 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant