-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix: MAP value converter for data via debezium #2156
Conversation
94f78ec
to
7ed4582
Compare
…um.data.Json converter to convert it properly for complex cases as well
8186ed4
to
0a22864
Compare
60744f0
to
2c9e33b
Compare
17d7f9a
to
b013864
Compare
9c10882
to
c996e46
Compare
7025d2c
to
ffbe291
Compare
c3d9a8c
to
7c6f2c1
Compare
7c6f2c1
to
15f04d6
Compare
case MAP: | ||
StringBuilder mapString = new StringBuilder(); | ||
for (Map.Entry<String, String> entry : ((HashMap<String, String>) fieldValue).entrySet()) { | ||
String key = entry.getKey(); |
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.
let's add debug logs before and after our transformation for the key and value.
migtests/scripts/run-test.sh
Outdated
@@ -136,6 +136,14 @@ main() { | |||
fi | |||
fi | |||
|
|||
if [ "${TEST_DIR}" = "${TESTS_DIR}/pg/datatypes" ]; then | |||
cat ${EXPORT_DIR}/data/hstore_example_data.sql |
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.
this is just for debugging? remove?
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
@@ -26,6 +26,7 @@ EXPECTED_ROW_COUNT = { | |||
'datetime_type2': 2, | |||
'null_and_default' :2, | |||
'decimal_types': 3, | |||
'hstore_example': 13, |
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.
let's also add data validations (for each row), for source-target, source-source-replica, target-source-replica(ignore if this is not supported).
You can use get_distinct_values_of_column_of_table
transformedMapValue = transformedMapValue + fmt.Sprintf("\"%s\"=>\"%s\",", key, value) | ||
} | ||
return fmt.Sprintf("'%s'", transformedMapValue[:len(transformedMapValue)-1]), nil //remove last comma and add quotes | ||
"MAP": func(columnValue string, formatIfRequired bool, dbzmSchema *schemareg.ColumnSchema) (string, error) { |
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.
- what about postgressuite? Do we re-use yugabytedbSuite?
- we have some implementation for "MAP" in oracleSuite as well. I don't imagine that is useful, since we won't have MAP coming from oracle source at all, so remove it?
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.
what about postgressuite? Do we re-use yugabytedbSuite?
yes we use the same for both
we have some implementation for "MAP" in oracleSuite as well. I don't imagine that is useful, since we won't have MAP coming from oracle source at all, so remove it?
yeah ok
@@ -130,6 +130,14 @@ def migration_completed_checks(tgt): | |||
expected_distinct_values = EXPECTED_DISNTICT_VALUES['v5'] | |||
tgt.assert_distinct_values_of_col("datatypes2", "v5", "public", | |||
None, expected_distinct_values = expected_distinct_values) | |||
|
|||
print("hstore_example:") |
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.
This would run for all of target, source-replica, source(in case of fb), right?
how is it passing for fb, if YB cdc connector does not support it?
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 it runs on all target, source, and source-replica.
For the fall-forward/fall-back
workflows we still run with the hstore_example
table and snapshot data is still present in all the DBs but the CDC events are not added for the target_delta i.e. after cutover to target. So only CDC events from target for hstore are not getting tested.
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
mapString.append("\""); | ||
mapString.append(key); | ||
mapString.append("\""); | ||
mapString.append(" => "); | ||
mapString.append("\""); | ||
mapString.append(val); | ||
mapString.append("\""); | ||
mapString.append(","); |
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.
@priyanshi-yb, do we have something like fmt.Sprintf()
in Java to use here?
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.
+1 that would be a better. No idea why I wrote it like this initially 😀
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.
There is this String.format()
which looks similar to fmt.Sprintf()
can fix that in a follow up PR.
Describe the changes in this pull request
hstore
datatype value converter (MAP) to convert values properly from debezium in debezium exporter.Unsupported datatype for live migration with fall-forward/fall-back
as gRPC connector doesn't support it yet.https://yugabyte.atlassian.net/browse/DB-14753
Describe if there are any user-facing changes
No
How was this pull request tested?
end-to-end tests
Does your PR have changes that can cause upgrade issues?