You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: SpannerChangeStreamsToBigQuery does not support null primary key column values. #831
In Spanner it is valid to have nullable columns in a primary key.
However, the way the pipeline reads values out of json here it seems like it is extracting null when a column in the primary key is null and passing that value to bigquery.
Bigquery does not seem accept this and throws "This field: XXX is not a record."
This is blocking us rolling out a new feature that relies on a null primary key column.
"location":"col2","message":"This field: col2 is not a record.","reason":"invalid"}],"index":0}}
Beam Version
Newer than 2.46.0
Relevant log output
{"message":{"keysJson":"{\"XXX\":null,\"XXX\":\"XXXX\",\"XXX\":\"XXX\"}","newValuesJson":"{}","commitTimestampSeconds":XXX,"commitTimestampNanos":XXX,"serverTransactionId":"XXX","isLastRecordInTransactionInPartition":false,"recordSequence":"XXX","tableName":"XXX","modType":"DELETE","valueCaptureType":"OLD_AND_NEW_VALUES","numberOfRecordsInTransaction":2,"numberOfPartitionsInTransaction":1,"_metadata_error":{"errors":[{"debugInfo":"","location":"XXX","message":"This field: XXX is not a record.","reason":"invalid"}],"index":0},"_metadata_retry_count":1},"error_message":{"errors":[{"debugInfo":"","location":"XXX","message":"This field: XXX is not a record.","reason":"invalid"}],"index":0}}
As a followup i dug deeper and i think the issue is that
val jsonObject =
JSONObject("{\"Col1\":null,\"Col2\":\"123\"}")
val v = j.get("Col1")
val isNull = v != null // TRUE, because JSONObject.NULL and not java null
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
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.
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.
Activity
[-][Bug]: SpannerChangeStreamsToBigQuery does not support null primary key values.[/-]rob-pomelo commentedon Jun 30, 2023
As a followup i dug deeper and i think the issue is that
Details on null: https://stleary.github.io/JSON-java/org/json/JSONObject.html#NULL
This differs from non PK fields where java null is used and works
DataflowTemplates/v2/googlecloud-to-googlecloud/src/main/java/com/google/cloud/teleport/v2/templates/spannerchangestreamstobigquery/schemautils/SpannerToBigQueryUtils.java
Line 142 in 1276f71
I think an explicit
isNullcheck and skip similar to the following would fix itDataflowTemplates/v2/googlecloud-to-googlecloud/src/main/java/com/google/cloud/teleport/v2/templates/spannerchangestreamstobigquery/schemautils/SpannerToBigQueryUtils.java
Line 209 in 1276f71
rob-pomelo commentedon Jul 27, 2023
hi any updates here?
github-actions commentedon May 20, 2024
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
rob-pomelo commentedon May 20, 2024
this still is not fixed
github-actions commentedon Jan 22, 2025
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
rob-pomelo commentedon Jan 22, 2025
still not fixed
github-actions commentedon Dec 20, 2025
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
rob-pomelo commentedon Dec 22, 2025
Still not fixed
github-actions commentedon Jun 20, 2026
This issue has been marked as stale due to 180 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the issue at any time. Thank you for your contributions.
rob-pomelo commentedon Jun 20, 2026
Still not fixed
mvanhorn commentedon Oct 23, 2026
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.
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.
#4471