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

[DBZ-PGYB] Fixed bug resulting a 0 value in case of pgoutput #151

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

vaibhav-yb
Copy link
Collaborator

@vaibhav-yb vaibhav-yb commented Aug 2, 2024

Problem

Suppose we have a column with a non-basic value like timestamp - the code for converting the values here is following:

if (connectorConfig.plugin().isYBOutput()) {
    if (value != null && !UnchangedToastedReplicationMessageColumn.isUnchangedToastedValue(value)) {
        value = converter.convert(((Object[]) value)[0]);
        Struct cell = new Struct(fields[i].schema());
        cell.put("value", value);
        cell.put("set", true);
        result.put(fields[i], cell);
    } else {
        result.put(fields[i], null);
    }
} else {
    result.put(fields[i], value);
}

The else block above has a missing line which should utilise a converter for the value.

Solution

This PR modifies the PostgresSchema#getTableSchemaBuilder method to return the default TableSchemaBuilder when the plugin is NOT yboutput.

Additionally, this PR fixes the else block in PGTableSchemaBuilder with the required conversion and adds tests verifying the same for pgoutput by adding the following logic:

...
else {
  value = converter.convert(value);
  result.put(fields[i], value);
}
...

@vaibhav-yb vaibhav-yb requested a review from suranjan August 2, 2024 10:30
@vaibhav-yb vaibhav-yb self-assigned this Aug 2, 2024
@vaibhav-yb vaibhav-yb merged commit 6a7e5d7 into ybdb-debezium-2.5.2 Aug 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants