Skip to content

[Data Validation] Add Primary Key IT - #4077

Open
aasthabharill wants to merge 5 commits into
mainfrom
dv-pk-it
Open

[Data Validation] Add Primary Key IT#4077
aasthabharill wants to merge 5 commits into
mainfrom
dv-pk-it

Conversation

@aasthabharill

@aasthabharill aasthabharill commented Jul 29, 2026

Copy link
Copy Markdown
Member

Call out:
Three test cases:

  1. Transformed primary keys (value change using custom transformation)
  2. Modified primary key columns (where PK columns are different in SQL and Spanner)
  3. Complex Avro datatype as PK column

The first one uses a transformation, and as seen in this PR, this needs to be run on DataflowRunner to avoid resource leaks. The rest of the test methods are functional and so have been configured to run on DirectRunner

@aasthabharill aasthabharill added the addition New feature or request label Jul 29, 2026
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.53%. Comparing base (8db9b60) to head (ceaf554).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##               main    #4077       +/-   ##
=============================================
+ Coverage     34.36%   62.53%   +28.17%     
- Complexity      522     3332     +2810     
=============================================
  Files           216      574      +358     
  Lines         13239    33685    +20446     
  Branches       1311     3696     +2385     
=============================================
+ Hits           4549    21066    +16517     
- Misses         8323    11528     +3205     
- Partials        367     1091      +724     
Components Coverage Δ
spanner-templates 87.56% <100.00%> (∅)
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration 89.28% <100.00%> (∅)
spanner-live-reverse-replication 83.46% <100.00%> (∅)
spanner-bulk-migration 92.24% <100.00%> (∅)
gcs-spanner-dv 88.56% <100.00%> (∅)
Files with missing lines Coverage Δ
...er/migrations/avro/GenericRecordTypeConvertor.java 96.29% <100.00%> (ø)

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

@aasthabharill
aasthabharill marked this pull request as ready for review July 29, 2026 14:29
@aasthabharill
aasthabharill requested a review from a team as a code owner July 29, 2026 14:29
@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 comprehensive integration testing for the GCS to Spanner data validation pipeline, specifically focusing on handling complex primary key configurations. It ensures that the pipeline correctly matches records when primary keys undergo transformations, differ between source and destination schemas, or utilize complex Avro datatypes. Additionally, a minor fix was applied to the record conversion logic to improve resilience during custom transformations.

Highlights

  • Integration Testing: Added a new integration test suite, GCSSpannerDVPrimaryKeyIT, to validate complex primary key scenarios in the GCS to Spanner data validation pipeline.
  • Test Coverage: Implemented three specific test cases: transformed primary keys, modified primary key columns between source and destination, and complex Avro datatypes as primary keys.
  • Code Robustness: Added a null check in GenericRecordTypeConvertor to safely handle cases where custom transformations return null response rows.
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 introduces a new integration test suite, GCSSpannerDVPrimaryKeyIT, along with its Spanner schema to verify complex primary key handling in the GCSSpannerDV pipeline, covering transformed primary keys, modified primary key columns, and complex Avro datatypes. Additionally, it adds a null check in GenericRecordTypeConvertor to prevent potential null pointer exceptions when custom transformations return null. The review feedback points out that using an Integer instead of a Long for the role_id field in the integration test can cause a ClassCastException during Avro serialization, and suggests using 1L instead.

@aasthabharill
aasthabharill marked this pull request as draft July 29, 2026 14:33
@aasthabharill
aasthabharill marked this pull request as ready for review July 29, 2026 16:09
@aasthabharill
aasthabharill requested a review from manitgupta July 29, 2026 16:09

@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 adds integration tests for complex primary key handling in the GCSSpannerDV pipeline and introduces a null check in GenericRecordTypeConvertor to prevent NullPointerExceptions when custom transformations return a null response row. The feedback suggests adding a 20-second delay in the testTransformedPrimaryKey integration test to prevent test flakiness due to Spanner's exact staleness read bound.

Comment on lines +99 to +100
.set("full_name")
.to("416c696365") // Hex for "Alice"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Is a hex transform is happening lets just call the column name appropriately, why full_name? Maybe user_id_in_hex or something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

because i was re-using the pre-defined USERS schema it had to be full_name as i didn't want to do column renaming in this test.

But in that spirit, i have changed the logic to use a different table_name so there is a dedicated transformation for this test

Comment on lines +264 to +266
if (transformedCols == null) {
return result;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was this needed?

@aasthabharill aasthabharill Jul 29, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The next line includes transformedCols.entrySet() which throws NullPointerException if transformedCols=null

Custom Transformation can return null in a lot of cases where a particular table is not transforming any rows and the code then fails with NullPointerException

@aasthabharill
aasthabharill requested a review from manitgupta July 29, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition New feature or request size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants