-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Pulsar IO][Issue 5633]Support avro schema for debezium connector #6034
[Pulsar IO][Issue 5633]Support avro schema for debezium connector #6034
Conversation
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.
@tuteng overall looks good. Can you add an integration test for it?
You are right, the current integration test has been covered, and this feature supports JSONSchema and AVROSchema. @sijie |
@@ -188,15 +198,48 @@ public void close() { | |||
@Getter | |||
Optional<String> destinationTopic; | |||
|
|||
private final AvroData avroData; | |||
|
|||
private org.apache.pulsar.kafka.shade.avro.Schema keyAvroSchema; |
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.
I don't think this needs to be a class variable. what method is using this variable except the constructor?
|
||
private org.apache.pulsar.kafka.shade.avro.Schema keyAvroSchema; | ||
|
||
private org.apache.pulsar.kafka.shade.avro.Schema valueAvroSchema; |
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.
same comments as above.
|
||
private final KafkaSchema valueSchema; | ||
|
||
private byte[] keyBytes; |
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.
why do we need to make this variable a class variable? it is only used in the constructor.
|
||
private byte[] keyBytes; | ||
|
||
private byte[] valueBytes; |
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.
same comment as above.
String keyName = this.topicName.get() + "-key"; | ||
String valueName = this.topicName.get() + "-value"; | ||
|
||
if (readerCache.getIfPresent(keyName) == null |
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.
actually I think the cache here is incorrect. you need a cache from kafka connect schema to pulsar schema.
Cache<org.apache.kafka.connect.data.Schema, KafkaSchema>
I have tried to build and run it.
I have made sure to delete all the existing schemas before running so the schema mutation error is not stem from leftover schema from previous runs. And if I use AvroConverter (org.apache.pulsar.kafka.shade.io.confluent.connect.avro.AvroConverter)
|
@tuteng What is the status for this PR? |
@dennisylyung Hi, could you provide some config info about the error logs, such as the pulsar source config and the reproduce steps, thanks. This is my test steps to follow the demo http://pulsar.apache.org/docs/en/io-debezium-source/#example-of-mysql, but I didn't reproduce your problem.
|
@gaoran10 is helping on this issue. |
This is the config I was using.
|
f3f1974
to
a94785f
Compare
I have made some changes, use the JsonConverter as before, and the AvroConverter is used differently from the JsonConverter, the user has two ways to use it.
@tuteng @sijie @jiazhai @codelipenghui Please have a review. Thanks. |
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.
I don't see how users pass offload to the schema info. Currently, users use SchemaDefination to create schemas, so it's better to add a method in the SchemaDefinationBuilder
.
And, we also need a doc to tell users how to consume messages from the topic that the debezium writes. If we have debezium connector related docs, it's better to add them directly. Otherwise, you can create a issue or a new doc for debezium connector.
@@ -47,6 +47,10 @@ | |||
private final List<Field> fields; | |||
private final Schema schema; | |||
private final byte[] schemaVersion; | |||
|
|||
private int offset; | |||
public final static String OFFSET_PROP = "AVRO_READ_OFFSET"; |
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 are two properties name definition in the SchemaDefinitionBuilderImpl
. I think you can move all of them to SchemaDefinition
and keep the with prefix "__".
/pulsarbot run-failure-checks |
1e71e0a
to
4e077b5
Compare
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
…ache#6034) Fixes apache#5633 ### Motivation Currently, some users want to support Avro schema in debezium, so this pr supports this feature. For Kafka's Avro schema, it depends on the Avro 1.8 version, but Avro version has just been upgraded to 1.9 in pulsar, so shade is needed to avoid finding `addProp` function ### Modifications * Add a package `kafka-connect-avro-converter-shaded` * Add class KafkaSchema to converter Kafka's Avro schema to pulsar's schema ### Verifying this change Unit test and integration tests
Doc has been added: https://pulsar.apache.org/docs/en/next/io-debezium-source/#converter-options |
…ache#6034) Fixes apache#5633 ### Motivation Currently, some users want to support Avro schema in debezium, so this pr supports this feature. For Kafka's Avro schema, it depends on the Avro 1.8 version, but Avro version has just been upgraded to 1.9 in pulsar, so shade is needed to avoid finding `addProp` function ### Modifications * Add a package `kafka-connect-avro-converter-shaded` * Add class KafkaSchema to converter Kafka's Avro schema to pulsar's schema ### Verifying this change Unit test and integration tests
Fixes #5633
Motivation
Currently, some users want to support Avro schema in debezium, so this pr supports this feature.
For Kafka's Avro schema, it depends on the Avro 1.8 version, but Avro version has just been upgraded to 1.9 in pulsar, so shade is needed to avoid finding
addProp
functionModifications
kafka-connect-avro-converter-shaded
Verifying this change
Unit test and integration tests