Skip to content

feat(datastream-to-SQL): Support DELETE replication for tables without Primary Keys using ROWID - #4232

Open
yonatandt wants to merge 9 commits into
mainfrom
feat/sql-rowid-fallback
Open

yonatandt wants to merge 9 commits into
mainfrom
feat/sql-rowid-fallback

Conversation

@yonatandt

Copy link
Copy Markdown
Contributor
  • Fix regression in DatastreamToDML where tables lacking primary keys produced empty WHERE clauses for DELETE events.
  • Add ROWID fallback in getPrimaryKeyToValueFilterSql when primaryKeys is empty or unmapped.
  • Allow getDmlTemplate to generate DELETE DML when rowid or _metadata_row_id is present.
  • Make DatastreamRow getPrimaryKeys and getStringValue null-safe against missing metadata fields.
  • Add unit tests verifying ROWID fallback in DatastreamToDMLTest and DatastreamRowTest.

Fixes b/506993545

@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 addresses a regression in the DatastreamToDML component where DELETE events for tables without primary keys were failing due to empty WHERE clauses. By implementing a ROWID fallback mechanism, the system can now correctly identify and process these deletions. Additionally, the changes improve the robustness of metadata field handling within DatastreamRow to ensure more reliable data processing.

Highlights

  • ROWID Support for DELETE: Added support for using ROWID as a fallback identifier for DELETE operations on tables that lack primary keys.
  • Null-Safety Improvements: Enhanced DatastreamRow to be null-safe when accessing metadata fields, preventing potential crashes during record processing.
  • Unit Testing: Introduced comprehensive unit tests in DatastreamToDMLTest and DatastreamRowTest to verify the new ROWID fallback logic and null-safety fixes.
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. ↩

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.36%. Comparing base (6e68e20) to head (03afd40).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...oogle/cloud/teleport/v2/utils/DatastreamToDML.java 78.57% 3 Missing and 9 partials ⚠️

❌ Your patch check has failed because the patch coverage (78.57%) 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    #4232   +/-   ##
=========================================
  Coverage     56.35%   56.36%           
- Complexity     7858     7875   +17     
=========================================
  Files          1154     1154           
  Lines         73194    73270   +76     
  Branches       8580     8606   +26     
=========================================
+ Hits          41252    41295   +43     
- Misses        29158    29177   +19     
- Partials       2784     2798   +14     
Components Coverage Δ
spanner-templates 84.48% <ø> (+<0.01%) ⬆️
spanner-import-export 68.91% <ø> (-0.15%) ⬇️
spanner-live-forward-migration 88.99% <ø> (+0.01%) ⬆️
spanner-live-reverse-replication 80.87% <ø> (+0.01%) ⬆️
spanner-bulk-migration 89.00% <ø> (+<0.01%) ⬆️
gcs-spanner-dv 88.11% <ø> (+0.01%) ⬆️
Files with missing lines Coverage Δ
...oogle/cloud/teleport/v2/utils/DatastreamToDML.java 44.35% <78.57%> (+9.48%) ⬆️

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

@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 introduces null-safety improvements in DatastreamRow when parsing JSON fields and primary keys, and adds fallback support for row IDs (rowid or _metadata_row_id) when generating DML templates and filters in DatastreamToDML for tables without primary keys. The feedback recommends handling column casing in the row ID fallback logic of getValueSql to prevent issues when casing rules are applied, and refactoring the primary key extraction in DatastreamRow to avoid redundant JSON node lookups.

@yonatandt
yonatandt force-pushed the feat/sql-rowid-fallback branch from da8f43e to 20c621d Compare September 8, 2026 13:23
- Fix regression in DatastreamToDML where tables lacking primary keys produced empty WHERE clauses for DELETE events.
- Add ROWID fallback in getPrimaryKeyToValueFilterSql when primaryKeys is empty or unmapped.
- Allow getDmlTemplate to generate DELETE DML when rowid or _metadata_row_id is present.
- Make DatastreamRow getPrimaryKeys and getStringValue null-safe against missing metadata fields.
- Add unit tests verifying ROWID fallback in DatastreamToDMLTest and DatastreamRowTest.

Fixes b/506993545
@yonatandt
yonatandt force-pushed the feat/sql-rowid-fallback branch from 255c22e to 72f2afb Compare September 17, 2026 09:39
@yonatandt
yonatandt force-pushed the feat/sql-rowid-fallback branch from 03afd40 to c2bc81b Compare September 24, 2026 11:37
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.

2 participants