4 Byte PK support - #4010
Conversation
Summary of ChangesHello, 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 4-byte character sets (such as emojis) in primary keys during source database to Spanner migrations. The changes involve refining the collation order logic for both MySQL and PostgreSQL to ensure these characters are correctly processed and validated, alongside new integration tests to validate the end-to-end migration flow. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request updates the collation order queries for MySQL and PostgreSQL to support 4-byte UTF-8 characters and adds corresponding integration tests. Feedback highlights a significant performance concern in the MySQL query due to the massive increase in rows (to over 1.1 million) processed during 4-byte codepoint generation, which could cause high CPU/IO load and disk sorting. Additionally, the new integration tests should be refactored to use instance fields instead of static fields for resource managers and to declare the Dataflow job info as a local variable.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4010 +/- ##
============================================
+ Coverage 55.74% 63.87% +8.12%
+ Complexity 7241 2685 -4556
============================================
Files 1124 556 -568
Lines 68476 31520 -36956
Branches 7726 3483 -4243
============================================
- Hits 38173 20132 -18041
+ Misses 27826 10353 -17473
+ Partials 2477 1035 -1442
🚀 New features to boost your workflow:
|
88454e5 to
5c85c66
Compare
818d1f6 to
64bdb18
Compare
bce030a to
1b0a869
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the collation mapping classes to use String instead of Character to support multi-byte characters (such as 4-byte UTF-8 emojis) and adds corresponding integration tests for MySQL and PostgreSQL. The review feedback highlights a critical bug where reference equality (== and !=) is used with BigInteger.ZERO instead of .equals(), which can lead to infinite loops during deserialization. Additionally, suggestions are provided to simplify padding calculations and use Java 8 streams for more idiomatic code point extraction.
bharadwaj-aditya
left a comment
There was a problem hiding this comment.
Thanks for putting this together. This flow looks a lot simpler.
This PR updates the uniform splitter to correctly handle 4-byte string characters (like emojis) in primary keys during SourceDB to Spanner migrations.
Previously, the string mapper used Java
chartypes. Sincecharis limited to 2 bytes, it cannot represent 4-byte characters without surrogate pairs. RefactoredCollationIndex,CollationMapper, andCollationOrderRowto useStringrepresentations instead. This removes the byte length constraints.I also updated the MySQL and PostgreSQL collation order SQL queries to accurately handle these characters in range calculations.
To verify the fixes, I added two new integration tests that copy tables with 4-byte primary keys:
MySQLSourceDbToSpanner4ByteStringPKITPostgreSQLSourceDbToSpanner4ByteStringPKITLogs showing all characters were captured:
MySQL
PG
I increased the DirectRunner test timeout to 15 minutes in
SourceDbToSpannerITBasealthough the tests use DataflowRunner in github actions so that we can test these tests locally using direct runner (the default timeout there was 4 min)