Repository navigation
fix(Spanner): Live: handle SQL Server datetime records and shard ids - #4498
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4498 +/- ##
============================================
+ Coverage 57.04% 57.06% +0.02%
- Complexity 7687 8145 +458
============================================
Files 1167 1167
Lines 74470 74484 +14
Branches 8810 8812 +2
============================================
+ Hits 42481 42504 +23
+ Misses 29149 29142 -7
+ Partials 2840 2838 -2
🚀 New features to boost your workflow:
|
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 improves the migration process from SQL Server to Spanner by addressing issues with how datetime data types are handled and enabling shard ID support. It ensures that complex datetime records are correctly parsed and converted, and it expands the support for sharding logic to include SQL Server sources, which improves the robustness of the migration pipeline. 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 adds support for replicating SQL Server datetime, datetime2, and smalldatetime columns from Datastream to Spanner by parsing the nested Avro datetime record (containing date and time fields) into UTC wall-clock values. It also enables SQL Server sharding support in ChangeEventSessionConvertor and updates integration tests to assert these changes. The review feedback highlights critical improvements to prevent silent data loss and corruption: specifically, ensuring that empty string checks for timestamp and date conversions only apply to textual nodes (to avoid misinterpreting failed parses of non-textual nodes as null), and making the parseDatetimeRecord helper more robust by verifying that the JSON node has exactly two numeric fields.
b25e435 to
de746b9
Compare
7a90f70 to
76d3895
Compare
bharadwaj-aditya
left a comment
There was a problem hiding this comment.
Couple of minor comments. Rest looks fine.
76d3895 to
b1b5879
Compare
- ChangeEventTypeConvertor: decode Datastream's SQL Server datetime Avro RECORD
({date: epoch days, time: micros}) for TIMESTAMP, DATE and STRING targets and
treat empty strings as NULL.
- ChangeEventSessionConvertor: populate migration_shard_id for sqlserver sources
(previously only mysql/oracle).
- SQLServerDatastreamToSpannerDataTypesIT: assert datetime, datetime2 and
smalldatetime values (TIMESTAMP, STRING and PK variants) instead of NULL only.
…treamRecordToJson Address review feedback: match the Datastream datetime Avro RECORD by its schema name where the record is flattened to JSON (next to timestampTz/timeTz) and emit an ISO-8601 UTC string, consistent with GenericRecordTypeConvertor in bulk migration. This removes the JSON-shape heuristic from ChangeEventTypeConvertor, which could misfire on user JSON containing date/time keys and swallowed unparsed objects as NULL, and it also fixes custom transformations receiving a nested Map for these columns.
1f52776 to
ff836a7
Compare
…ot swallowed executeSqlScript joins the script lines with spaces before splitting on ';', so a '--' comment that is not terminated by ';' comments out the following statement. The comments added before the datetime2_table and datetime_table inserts swallowed those inserts, leaving the tables empty on the source and timing out SQLServerDatastreamToSpannerDataTypesIT. End them with ';' like the other comment blocks in the file.
25822d9 to
48d1be4
Compare
datetimeAvro RECORD ({date: epoch days, time: micros}) into an ISO-8601 UTC wall-clock string (usingfloorDiv/floorMod, so pre-1970 values are correct). DownstreamChangeEventTypeConvertoralready parses that string for TIMESTAMP, DATE and STRING targets, and custom transformations now receive a string instead of a nested map.