-
Notifications
You must be signed in to change notification settings - Fork 988
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
Custom transformation for Cassandra to Spanner SourceDB #2201
base: main
Are you sure you want to change the base?
Custom transformation for Cassandra to Spanner SourceDB #2201
Conversation
* sync upstream/main (#98) * Custom transformation fixes * Added Custom Transformation * Added Custom Transformation * Added Fixes * Address null to all columns * Added Null Assert * Added Timeout fixes * Added Spotless fixes * reverse merge the main * Added Custom Fixes * Added Drop Keys ---------
Move null test case into previous tests
Referesh `SpannerToSourceDbCustomTransformationIT` tables for re-runs…
@@ -78,6 +79,7 @@ public class SpannerToCassandraSourceDbIT extends SpannerToSourceDbITBase { | |||
private static final String USER_TABLE = "Users"; | |||
private static final String USER_TABLE_2 = "Users2"; | |||
private static final String ALL_DATA_TYPES_TABLE = "AllDatatypeColumns"; | |||
private static final String ALL_DATA_TYPES_TABLE_FOR_NULL_KEY = "AllDataTypeColumnsForNullKey"; |
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.
not required?
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.
@shreyakhajanchi went unknowingly, I have removed the same will able to reflect soon
Mutation.newInsertOrUpdateBuilder(ALL_DATA_TYPES_TABLE) | ||
.set("varchar_column") | ||
.to("SampleVarcharForNull") // Only this column has a value | ||
.set("tinyint_column") |
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.
why set null for others, we can simply skip setting other columns and it will be NULL automatically, right?
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.
@shreyakhajanchi as per our discussion we are going to add another case where we are going to add only value for the primary key alone
@@ -538,8 +631,8 @@ private void assertAllDataTypeRowsInCassandraDB() | |||
PipelineOperator.Result result = | |||
pipelineOperator() | |||
.waitForCondition( | |||
createConfig(jobInfo, Duration.ofMinutes(10)), | |||
() -> getRowCount(ALL_DATA_TYPES_TABLE) == 1); | |||
createConfig(jobInfo, Duration.ofMinutes(20)), |
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.
Is it taking more than 10 min?
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.
No @shreyakhajanchi Will reduce to 10
"first_name" text, | ||
"last_name" text |
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.
why are these two columns in quotes?
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.
Yes we can remove
DROP TABLE IF EXISTS customers; | ||
CREATE TABLE IF NOT EXISTS customers ( | ||
id INT64 NOT NULL, | ||
full_name STRING(125), |
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.
full_name
column not required in spanner schema?
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.
Yes @shreyakhajanchi as we are trying to populate full name in Cassandra based on FirstName and lastName
@@ -210,7 +212,8 @@ private void assertDeleteRowInCassandraDB() throws InterruptedException { | |||
PipelineOperator.Result result = | |||
pipelineOperator() | |||
.waitForCondition( | |||
createConfig(jobInfo, Duration.ofMinutes(10)), () -> getRowCount(USER_TABLE) == 0); | |||
createConfig(jobInfo, Duration.ofMinutes(10)), | |||
() -> getRowCount(USER_TABLE_2) == 0); |
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.
I guess this should still be USER_TABLE and and the table in below should change because the writes to users2 is with txn tag and is filtered:
private void writeDeleteInSpanner() {
Mutation insertOrUpdateMutation =
Mutation.newInsertOrUpdateBuilder(USER_TABLE_2)
.set("id")
.to(4)
.set("full_name")
.to("GG")
.build();
spannerResourceManager.write(insertOrUpdateMutation);
KeySet allRows = KeySet.all();
Mutation deleteAllMutation = Mutation.delete(USER_TABLE_2, allRows);
spannerResourceManager.write(deleteAllMutation);
}
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.
@shreyakhajanchi Address the same
spannerResourceManager.write(m1); | ||
} | ||
|
||
/** |
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.
Remove these elaborate comments, the methods are self explainatory
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.
Sure @shreyakhajanchi
if (request.getEventType().equals("UPDATE")) { | ||
return new MigrationTransformationResponse(null, false); | ||
} | ||
if (request.getEventType().equals("DELETE")) { | ||
return new MigrationTransformationResponse(null, true); | ||
} |
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.
not required
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.
@shreyakhajanchi as per current logic in IT we are populating full name based on first name and last name so I guess it is need to be here
if (request.getTableName().equals("Customers")) { | ||
Map<String, Object> row = new HashMap<>(request.getRequestRow()); | ||
row.put("full_name", row.get("first_name") + " " + row.get("last_name")); | ||
row.put("migration_shard_id", request.getShardId() + "_" + row.get("id")); | ||
MigrationTransformationResponse response = new MigrationTransformationResponse(row, false); | ||
return response; | ||
} |
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.
not required
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.
@shreyakhajanchi as per current logic in IT we are populating full name based on first name and last name so I guess it is need to be here
@@ -0,0 +1,70 @@ | |||
/* | |||
* Copyright (C) 2024 Google LLC |
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.
2025
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.
@shreyakhajanchi address the same
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2201 +/- ##
============================================
- Coverage 47.06% 47.05% -0.01%
- Complexity 4048 4378 +330
============================================
Files 876 877 +1
Lines 52223 52270 +47
Branches 5505 5515 +10
============================================
+ Hits 24577 24594 +17
- Misses 25885 25911 +26
- Partials 1761 1765 +4
|
This pull request introduces the following key enhancements: