-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[datastream-to-spanner] Unable to convert field timestamp to long #3035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[datastream-to-spanner] Unable to convert field timestamp to long #3035
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3035 +/- ##
============================================
+ Coverage 50.39% 54.20% +3.80%
+ Complexity 5021 2157 -2864
============================================
Files 970 488 -482
Lines 59606 28151 -31455
Branches 6507 2946 -3561
============================================
- Hits 30039 15259 -14780
+ Misses 27441 11954 -15487
+ Partials 2126 938 -1188
🚀 New features to boost your workflow:
|
...ner/src/main/java/com/google/cloud/teleport/v2/templates/datastream/DatastreamConstants.java
Outdated
Show resolved
Hide resolved
...nner/src/main/java/com/google/cloud/teleport/v2/templates/datastream/ChangeEventContext.java
Outdated
Show resolved
Hide resolved
...spanner/src/main/java/com/google/cloud/teleport/v2/templates/spanner/ShadowTableCreator.java
Outdated
Show resolved
Hide resolved
VardhanThigle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
...er/src/main/java/com/google/cloud/teleport/v2/templates/datastream/ChangeEventConvertor.java
Outdated
Show resolved
Hide resolved
...nner/src/main/java/com/google/cloud/teleport/v2/templates/datastream/ChangeEventContext.java
Outdated
Show resolved
Hide resolved
shreyakhajanchi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please merge once the tests pass
fd8e6a2 to
012d9af
Compare
012d9af to
3faf25e
Compare
…ogleCloudPlatform#3035) [b/458064173](https://b.corp.google.com/issues/458064173) #### Problem We create some new columns to hold metadata in the shadow tables that are created. These shadow tables also have the Primary Key columns from the data table. When the data table has columns of the same name as the metadata columns we create, it gets overwritten because of which we get data type conversion errors. For eg. a primary key column "timestamp TIMESTAMP" gets overwritten to "timestamp INT64". #### Fix To ensure that we don't have these kind of clashes, we now dynamically compute the name of the shadow column by checking it against the list of primary key column names. In case a column with the same name is found, we add "shadow_" as a prefix iteratively till we get a unique column name for the shadow table. ### Testing: - Built container with changes: gs://ea-functional-tests/templates-aastha-2025-12-09/flex/Cloud_Datastream_to_Spanner - Confirmed in DDL of Shadow table that original "timestamp" column of type TIMESTAMP is present along with new columns: shadow_timestamp, log_file and log_position - Ran a live migration job with above template and ran INSERT, UPDATE and DELETE statements containing "timestamp TIMESTAMP" column as Primary Key in data table - and these passed without errors
b/458064173
Problem
We create some new columns to hold metadata in the shadow tables that are created. These shadow tables also have the Primary Key columns from the data table. When the data table has columns of the same name as the metadata columns we create, it gets overwritten because of which we get data type conversion errors. For eg. a primary key column "timestamp TIMESTAMP" gets overwritten to "timestamp INT64".
Fix
To ensure that we don't have these kind of clashes, we now dynamically compute the name of the shadow column by checking it against the list of primary key column names. In case a column with the same name is found, we add "shadow_" as a prefix iteratively till we get a unique column name for the shadow table.
Testing: