I have a Kafka-Connect job configured to query a MySQL table periodically and place messages on a queue. The structure of these messages are defined using an Avro schema. I am having an issue with the mapping for one of my columns.
The column is defined as a tinyint(1) in my MySQL schema, and I am trying to map this to a boolean field in my avro object.
{
"name": "is_active",
"type": "boolean"
}
The kafka-connect jobs runs, and messages are placed on the queue, but when my application who reads from the queue attempts to deserialize the messages I get the following error:
org.apache.avro.AvroTypeException: Found int, expecting boolean
I was hoping that a 1 or 0 value could be automatically mapped to a boolean, but that does not seem to be the case.
I have also tried to configure my job to use a 'Cast' transform, but that just seems to caused issues with the other fields in the message.
"transforms": "Cast",
"transforms.Cast.type": "org.apache.kafka.connect.transforms.Cast$Value",
"transforms.Cast.spec": "is_active:boolean"
Is what I am attempting possible, or will I have to change my application to work with the int value?
Here is my full configuration ( I have stripped out some other irrelevant fields )
Kafka Connect job config
{
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"mode": "bulk",
"topic.prefix": "my_topic-name",
"transforms.SetSchemaMetadata.type": "org.apache.kafka.connect.transforms.SetSchemaMetadata$Value",
"query": "select is_active from my_table",
"poll.interval.ms": "30000",
"transforms": "SetSchemaMetadata",
"name": "job_name",
"connection.url": "connectiondetailshere",
"transforms.SetSchemaMetadata.schema.name": "com.my.model.name"
}
AVRO Schema
{
"type": "record",
"name": "name",
"namespace": "com.my.model",
"fields": [
{
"name": "is_active",
"type": "long"
}
],
"connect.name": "com.my.model.name"
}