Skip to content

Spanner bulk data migration: Add support for DECIMAL as a primary key#3119

Merged
VardhanThigle merged 15 commits intoGoogleCloudPlatform:mainfrom
nmemond:source-to-spanner-mysql-decimal-pk
Dec 18, 2025
Merged

Spanner bulk data migration: Add support for DECIMAL as a primary key#3119
VardhanThigle merged 15 commits intoGoogleCloudPlatform:mainfrom
nmemond:source-to-spanner-mysql-decimal-pk

Conversation

@nmemond
Copy link
Contributor

@nmemond nmemond commented Dec 16, 2025

This is a copy of #3087 but up-to-date with main and with issues fixed, because that developer is out of office for the rest of the year and I don't have permissions to push to their fork.

@nmemond nmemond requested a review from a team as a code owner December 16, 2025 16:33
@gemini-code-assist
Copy link

Summary of Changes

Hello @nmemond, 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 robust support for DECIMAL data types when they are used as primary keys in source databases for Spanner bulk data migration. It addresses the need to accurately represent and partition DECIMAL values by integrating their numericScale into the data processing pipeline. This ensures that migrations involving tables with DECIMAL primary keys are performed correctly and efficiently, preventing data integrity issues and improving the overall reliability of the migration process.

Highlights

  • DECIMAL Primary Key Support: The Spanner bulk data migration tool now supports DECIMAL data types as primary keys, enhancing its compatibility with source databases that utilize this type for indexing.
  • Numeric Scale Handling: The system has been updated to correctly extract and utilize the numericScale property of DECIMAL columns, which is crucial for accurate partitioning and splitting of BigDecimal values during data migration.
  • Refactored BigDecimal Splitting Logic: The internal BigDecimal splitting mechanism has been refactored to incorporate the numericScale, ensuring that split points are calculated precisely according to the decimal precision of the column.
  • Comprehensive Testing: New unit and integration tests have been added to validate the correct handling of DECIMAL primary keys, including schema discovery, boundary extraction, and splitting logic, along with updated MySQL and Spanner schema definitions.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.88%. Comparing base (d34cbde) to head (4497991).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3119      +/-   ##
============================================
+ Coverage     50.54%   55.88%   +5.34%     
+ Complexity     5047     1642    -3405     
============================================
  Files           974      471     -503     
  Lines         59808    26523   -33285     
  Branches       6523     2781    -3742     
============================================
- Hits          30230    14823   -15407     
+ Misses        27443    10802   -16641     
+ Partials       2135      898    -1237     
Components Coverage Δ
spanner-templates 71.85% <100.00%> (+1.07%) ⬆️
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration 80.04% <ø> (ø)
spanner-live-reverse-replication 77.68% <ø> (-0.05%) ⬇️
spanner-bulk-migration 88.28% <100.00%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
...jdbc/dialectadapter/mysql/MysqlDialectAdapter.java 99.62% <100.00%> (+<0.01%) ⬆️
...source/reader/io/jdbc/iowrapper/JdbcIoWrapper.java 92.93% <100.00%> (+0.03%) ⬆️
...reader/io/jdbc/uniformsplitter/range/Boundary.java 98.46% <100.00%> (+0.07%) ⬆️
...uniformsplitter/range/BoundarySplitterFactory.java 100.00% <100.00%> (ø)
...io/jdbc/uniformsplitter/range/PartitionColumn.java 94.73% <100.00%> (+1.87%) ⬆️
...source/reader/io/schema/SourceColumnIndexInfo.java 69.23% <100.00%> (+1.23%) ⬆️

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

@VardhanThigle
Copy link
Contributor

Please rebase This PR on top of the tree code.

@VardhanThigle VardhanThigle merged commit c2cd0e5 into GoogleCloudPlatform:main Dec 18, 2025
14 checks passed
@nmemond nmemond deleted the source-to-spanner-mysql-decimal-pk branch December 18, 2025 13:55
MnkyGns pushed a commit to MnkyGns/DataflowTemplates that referenced this pull request Feb 12, 2026
…GoogleCloudPlatform#3119)

* add DECIMAL type support as primary key

* fix spotless error

* Update MysqlDialectAdapterTest.java

* fix spotless

* add DECIMAL PK with precision/scale

* update BigDecimal splitter to handle scale correctly

* Add BigDecimal boundary splitter with precision-aware equality and splittability checks

* Fix DECIMAL type mapping to use BigDecimal splitter

* Support DECIMAL columns with precision-aware splitting

* Fix compilation issues and test failures

* Address PR feedback

---------

Co-authored-by: gpalanisamyYopp <gayathri.palanisamy@improving.com>
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.

3 participants