Skip to content
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

Adding IT for custom transformation in new reverse replication template #2056

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"commitTimestamp":{"seconds":1719247984,"nanos":109263000},"serverTransactionId":"NzkxOTE5OTY4NTQzNjMzODY3Mg\u003d\u003d","recordSequence":"00000000","tableName":"Users","mods":[{"keysJson":"{\"id\":\"1\"}","oldValuesJson":"{}","newValuesJson":"{\"name\":\"FF\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1719846465,"nanos":372383000},"serverTransactionId":"Mjk0MTkyNDQ4NzkyMDcyMzcwOQ\u003d\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example2\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"YmluX2NvbHVtbg\u003d\u003d\",\"bit_column\":\"MQ\u003d\u003d\",\"blob_column\":\"YmxvYl9jb2x1bW4\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 2\",\"time_column\":\"410000\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"2\",\"year_column\":\"2024\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1719846503,"nanos":617919000},"serverTransactionId":"MTY0MDExNjY5NDAxMjEwMDA5Mzg\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example2\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"YmluX2NvbHVtbg\u003d\u003d\",\"bit_column\":\"MQ\u003d\u003d\",\"blob_column\":\"YmxvYl9jb2x1bW4\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 2\",\"time_column\":\"143000\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"2\",\"year_column\":\"2024\"}"}],"modType":"UPDATE","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1719846503,"nanos":617919000},"serverTransactionId":"MTY0MDExNjY5NDAxMjEwMDA5Mzg\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example2\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"YmluX2NvbHVtbg\u003d\u003d\",\"bit_column\":\"MQ\u003d\u003d\",\"blob_column\":\"YmxvYl9jb2x1bW4\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 2\",\"time_column\":\"143000\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"2\",\"year_column\":\"2024\"}"}],"modType":"DELETE","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1718795517,"nanos":877439000},"serverTransactionId":"MTI4NTc0NTY4OTYwMzkxMDgyNA\u003d\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example1\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"ZXhhbXBsZWJpbmFyeTE\u003d\",\"bit_column\":\"ZXhhbXBsZWJpdDE\u003d\",\"blob_column\":\"ZXhhbXBsZWJsb2Ix\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 1\",\"time_column\":\"143000\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"1\",\"year_column\":\"2024\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1718781240,"nanos":419055000},"serverTransactionId":"MTQxMTQ5MzExNTc0NTkyNzAzODM\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"12345\",\"binary_column\":\"U29tZSBiaW5hcnkgZGF0YQ\u003d\u003d\",\"bit_column\":\"U29tZSBiaW5hcnkgZGF0YQ\u003d\u003d\",\"blob_column\":\"U29tZSBiaW5hcnkgZGF0YQ\u003d\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"12345.67\",\"double_column\":123.456,\"enum_column\":\"1\",\"float_column\":123.45,\"int_column\":\"123\",\"text_column\":\"Sample text\",\"time_column\":\"143000\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"1\",\"year_column\":\"2024\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1719846465,"nanos":372383000},"serverTransactionId":"Mjk0MTkyNDQ4NzkyMDcyMzcwOQ\u003d\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example2\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"YmluX2NvbHVtbg\u003d\u003d\",\"bit_column\":\"MQ\u003d\u003d\",\"blob_column\":\"YmxvYl9jb2x1bW4\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 2\",\"time_column\":\"14:30:00\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"2\",\"year_column\":\"2024\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1719846503,"nanos":617919000},"serverTransactionId":"MTY0MDExNjY5NDAxMjEwMDA5Mzg\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example2\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"YmluX2NvbHVtbg\u003d\u003d\",\"bit_column\":\"MQ\u003d\u003d\",\"blob_column\":\"YmxvYl9jb2x1bW4\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 2\",\"time_column\":\"14:30:00\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"2\",\"year_column\":\"2024\"}"}],"modType":"UPDATE","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1719846503,"nanos":617919000},"serverTransactionId":"MTY0MDExNjY5NDAxMjEwMDA5Mzg\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example2\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"YmluX2NvbHVtbg\u003d\u003d\",\"bit_column\":\"MQ\u003d\u003d\",\"blob_column\":\"YmxvYl9jb2x1bW4\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 2\",\"time_column\":\"14:30:00\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"2\",\"year_column\":\"2024\"}"}],"modType":"DELETE","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1718795517,"nanos":877439000},"serverTransactionId":"MTI4NTc0NTY4OTYwMzkxMDgyNA\u003d\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example1\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"1000\",\"binary_column\":\"ZXhhbXBsZWJpbmFyeTE\u003d\",\"bit_column\":\"ZXhhbXBsZWJpdDE\u003d\",\"blob_column\":\"ZXhhbXBsZWJsb2Ix\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"99999.99\",\"double_column\":123456.123,\"enum_column\":\"1\",\"float_column\":12345.67,\"int_column\":\"100\",\"text_column\":\"Sample text for entry 1\",\"time_column\":\"14:30:00\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"1\",\"year_column\":\"2024\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
{"commitTimestamp":{"seconds":1718781240,"nanos":419055000},"serverTransactionId":"MTQxMTQ5MzExNTc0NTkyNzAzODM\u003d","recordSequence":"00000000","tableName":"AllDatatypeTransformation","mods":[{"keysJson":"{\"varchar_column\":\"example\"}","oldValuesJson":"{}","newValuesJson":"{\"bigint_column\":\"12345\",\"binary_column\":\"U29tZSBiaW5hcnkgZGF0YQ\u003d\u003d\",\"bit_column\":\"U29tZSBiaW5hcnkgZGF0YQ\u003d\u003d\",\"blob_column\":\"U29tZSBiaW5hcnkgZGF0YQ\u003d\u003d\",\"bool_column\":true,\"date_column\":\"2024-01-01\",\"datetime_column\":\"2024-01-01T12:34:56Z\",\"decimal_column\":\"12345.67\",\"double_column\":123.456,\"enum_column\":\"1\",\"float_column\":123.45,\"int_column\":\"123\",\"text_column\":\"Sample text\",\"time_column\":\"14:30:00\",\"timestamp_column\":\"2024-01-01T12:34:56Z\",\"tinyint_column\":\"1\",\"year_column\":\"2024\"}"}],"modType":"INSERT","numberOfRecordsInTransaction":1,"transactionTag":"","shard":"ls1"}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ public MigrationTransformationResponse toSourceRow(MigrationTransformationReques
Long tinyIntColumn = Long.parseLong((String) requestRow.get("tinyint_column")) + 1;
Long intColumn = Long.parseLong((String) requestRow.get("int_column")) + 1;
Long bigIntColumn = Long.parseLong((String) requestRow.get("bigint_column")) + 1;
Long timeColumn = Long.parseLong((String) requestRow.get("time_column")) + 1000;
Long yearColumn = Long.parseLong((String) requestRow.get("year_column")) + 1;
BigDecimal floatColumn = (BigDecimal) requestRow.get("float_column");
BigDecimal doubleColumn = (BigDecimal) requestRow.get("double_column");
Expand All @@ -143,7 +142,6 @@ public MigrationTransformationResponse toSourceRow(MigrationTransformationReques
responseRow.put("double_column", doubleColumn.add(BigDecimal.ONE).toString());
Double value = Double.parseDouble((String) requestRow.get("decimal_column"));
responseRow.put("decimal_column", String.valueOf(value - 1));
responseRow.put("time_column", "\'" + timeColumn + "\'");
responseRow.put("bool_column", "false");
responseRow.put("enum_column", "\'3\'");
responseRow.put(
Expand Down Expand Up @@ -191,11 +189,26 @@ public MigrationTransformationResponse toSourceRow(MigrationTransformationReques
"CONVERT_TZ(\'"
+ timestampColumn.substring(0, timestampColumn.length() - 1)
+ "\','+00:00','+00:00')");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime time = LocalTime.parse((String) requestRow.get("time_column"), formatter);

LocalTime newTime = time.plusMinutes(10);
responseRow.put("time_column", "\'" + newTime.format(formatter) + "\'");

} catch (Exception e) {
throw new InvalidTransformationException(e);
}

MigrationTransformationResponse response =
new MigrationTransformationResponse(responseRow, false);
return response;
} else if (request.getTableName().equals("Users1")) {
Map<String, Object> responseRow = new HashMap<>();
Map<String, Object> requestRow = request.getRequestRow();
String name = requestRow.get("name").toString();
String[] nameArray = name.split(" ");
responseRow.put("first_name", "\'" + nameArray[0] + "\'");
responseRow.put("last_name", "\'" + nameArray[1] + "\'");
MigrationTransformationResponse response =
new MigrationTransformationResponse(responseRow, false);
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public void setUp() throws IOException, InterruptedException {
getClass().getSimpleName(),
"input/customShard.jar",
"com.custom.CustomShardIdFetcherForIT",
null,
null);
}
}
Expand Down
Loading
Loading