Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone field in Kafka Connect?

I'm configuring Kafka Connect to copy data from Kafka to Database

I need to put value from some field to two column in Database .

My Kafka Message has two fields name, age. Target table has 3 columns name, displayName and age. I would like to clone value of name from Kafka message to put it in both columns name and displayName.

Is there any Transform, that can by applied to do that?

like image 838
Bartosz Wardziński Avatar asked Dec 06 '25 03:12

Bartosz Wardziński


1 Answers

As Driss Nejjar says, this would typically be the kind of thing that a Single Message Transform would be perfect for. However, there is no Transform that ships with Apache Kafka that I can see that would do this. You could write your own, or you could also use KSQL:

CREATE STREAM new AS SELECT name, name as displayName, age FROM source;

This would take your source topic (populated by Connect), and add the additional field displayName, and write to a new Kafka topic called new.

Disclaimer: I work for Confluent, the company behind the KSQL project.

like image 50
Robin Moffatt Avatar answered Dec 08 '25 23:12

Robin Moffatt