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

[cdc]Fixed When the order of the same field differs, it is considered a schema change. #3314

Merged
Merged
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
Expand Up @@ -45,14 +45,29 @@ public List<DataField> parseSchemaChange() {
.forEach(
dataField -> {
DataField previous = previousDataFields.get(dataField.name());
if (!Objects.equals(previous, dataField)) {
// When the order of the same field is different, its ID may also be
// different,
// so the comparison should not include the ID.
if (!dataFieldEqualsIgnoreId(previous, dataField)) {
previousDataFields.put(dataField.name(), dataField);
change.add(dataField);
}
});
return change;
}

private boolean dataFieldEqualsIgnoreId(DataField dataField1, DataField dataField2) {
if (dataField1 == dataField2) {
return true;
} else if (dataField1 != null && dataField2 != null) {
return Objects.equals(dataField1.name(), dataField2.name())
&& Objects.equals(dataField1.type(), dataField2.type())
&& Objects.equals(dataField1.description(), dataField2.description());
} else {
return false;
}
}

@Override
public List<CdcRecord> parseRecords() {
if (record.hasPayload()) {
Expand Down
Loading