Repository navigation
Conversation
If a primary-key name is present and JSON-null, key construction appends
a null string and skips the typed getter, and the BigQuery row stores
Java null instead of the sentinel. Missing keys still fail. Tests cover
the composite key {"Col1":"123","Col2":null} for both the Spanner key
and the table row.
Fixes GoogleCloudPlatform#831
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 addresses an issue where Spanner change streams containing nullable primary keys failed to load into BigQuery. The root cause was the JSON parser's use of a sentinel object (JSONObject.NULL) which BigQuery rejected as an invalid record type. The changes ensure that null primary key components are correctly translated to Java nulls, allowing successful data replication. 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 handling for explicit JSON null values (JSONObject.NULL) when processing Spanner change streams. In SpannerChangeStreamsUtils, a typed null is now appended to the Spanner key builder, and in SpannerToBigQueryUtils, a Java null is set in the TableRow to prevent BigQuery from rejecting the sentinel value. Corresponding unit tests have been added to verify these changes. I have no further feedback to provide as there are no review comments.
|
The required label check is failing because the PR has none of the release-note labels, and I don't have permission to add labels in this repo. Could a maintainer add bug-fix? The change fixes #831 (null primary key columns in Spanner change streams to BigQuery). |
|
cc: @chenxuesdu and @jiangzzhu |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4471 +/- ##
============================================
- Coverage 62.66% 56.96% -5.71%
- Complexity 3570 7579 +4009
============================================
Files 607 1158 +551
Lines 35213 73853 +38640
Branches 4001 8701 +4700
============================================
+ Hits 22067 42069 +20002
- Misses 12026 28982 +16956
- Partials 1120 2802 +1682
🚀 New features to boost your workflow:
|
Background
BigQuery rejects the row because that field is not a record, so tables with a nullable primary key cannot be replicated. Change-stream rows whose primary key contains a null column fail to load into BigQuery.
The keys JSON parser represents a JSON null as the JSONObject.NULL sentinel, not Java null. That sentinel is copied onto the BigQuery row, and the typed key getters reject it. Non-key columns already store Java null, which BigQuery accepts.
Summary of the fix
If a primary-key name is present and JSON-null, key construction appends a null string and skips the typed getter, and the BigQuery row stores Java null instead of the sentinel. Missing keys still fail. Tests cover the composite key {"Col1":"123","Col2":null} for both the Spanner key and the table row.
Verification
Tests for the DataflowTemplates SpannerChangeStreamsUtils change live in
v2/googlecloud-to-googlecloud/src/test/java/com/google/cloud/teleport/v2/templates/spannerchangestreamstobigquery/schemautils/SpannerChangeStreamsUtilsTest.javaandv2/googlecloud-to-googlecloud/src/test/java/com/google/cloud/teleport/v2/templates/spannerchangestreamstobigquery/schemautils/SpannerToBigQueryUtilsTest.java. The targeted tests for the DataflowTemplates SpannerChangeStreamsUtils change pass locally.Fixes #831