-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[FLINK-17149][debezium][canal] Introduce Debezium and Canal changelog format #12152
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
Conversation
|
cc @danny0405 |
|
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 81d1f17 (Thu May 14 12:17:34 UTC 2020) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. DetailsThe Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
…ading debezium changelogs
…ng canal changelogs
81d1f17 to
4ddbfe9
Compare
| } else { | ||
| if (!ignoreParseErrors) { | ||
| throw new IOException(format("Failed to deserialize Debezium JSON '%s'.", new String(message))); | ||
| } |
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.
Give more detailed message about why the deserialization fails.
| */ | ||
| public class DebeziumFormatFactory implements DeserializationFormatFactory, SerializationFormatFactory { | ||
|
|
||
| public static final String IDENTIFIER = "debezium-json"; |
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.
DebeziumJsonFormatFactory or maybe we can make the underlying format configurable.
| RowData row = jsonDeserializer.deserialize(message); | ||
| String type = row.getString(2).toString(); // "type" field | ||
| if (OP_INSERT.equals(type)) { | ||
| // "data" field is an array of row, contains inserted rows |
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.
Replace the if else clause with switch case seems better.
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.
It's not easy to rewrite in switch case, because we can't allocate local variable with the same name.
| if (before.isNullAt(f)) { | ||
| // not null fields in "old" (before) means the fields are changed | ||
| // null/empty fields in "old" (before) means the fields not not changed | ||
| // so we just copy the not changed fields into before |
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 not changed => are not changed
| } else { | ||
| if (!ignoreParseErrors) { | ||
| throw new IOException(format("Failed to deserialize Canal JSON '%s'.", new String(message))); | ||
| } |
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.
Give more detailed exception for an intentionally thrown exception.
| */ | ||
| public class CanalFormatFactory implements DeserializationFormatFactory, SerializationFormatFactory { | ||
|
|
||
| public static final String IDENTIFIER = "canal-json"; |
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.
CanalJsonFormatFactory ? or makes the underlying format configurable because Canal default format is Protobuf
| } | ||
|
|
||
| // Debezium captures change data (`debezium-data-schema-include.txt`) on the `product` table: | ||
| // |
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.
Canal ?
|
Thanks for the reviewing @danny0405 . PR updated. |
danny0405
left a comment
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, LGTM.
|
Thanks for the reviewing @danny0405 . Merging... |
|
The failed kafka case is related to FLINK-16383. |
What is the purpose of the change
Introduce
DebeziumFormatFactoryandCanalFormatFactoryto read changelogs.Brief change log
DebeziumJsonDeserializationSchemaandDebeziumFormatFactoryto deserialize Debezium messages.CanalJsonDeserializationSchemaandCanalFormatFactoryto deserialize Canal messages.DebeziumFormatFactory#createSinkFormatandCanalFormatFactory#createSinkFormatto tell users they can't be as sink for now.Verifying this change
DebeziumJsonDeserializationSchemaTestandCanalsonDeserializationSchemaTestto deserialize debezium messages and canal messages.DebeziumFormatFactoryTestandCanalFormatFactoryTestto unit test factories.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation