James Mark
James Mark

Reputation: 349

Kafka connect transforms (SMT) - Help to resolve the use case

I have a use case where i would like to map my source table key field to target table reference field using kafka source or sink connector.

I am new to this forum, pleas let me know if i am missing to add any information. Thanks in advance!

Upvotes: 0

Views: 2441

Answers (1)

Bartosz Wardziński
Bartosz Wardziński

Reputation: 6613

You should use: org.apache.kafka.connect.transforms.ReplaceField$Value Transformation

Configuration section with Transformation should looks like follow:

{
    ...
    "transforms": "RenameField",
    "transforms.RenameField.type": "org.apache.kafka.connect.transforms.ReplaceField$Value",
    "transforms.RenameField.renames": "SRC_ID:SRC_REF_ID"
    ...
}

If your column SRC_ID is of type Int you might also need casting to String. For that you can use: org.apache.kafka.connect.transforms.Cast

More detail about default Transformation can be found: https://kafka.apache.org/documentation/#connect_transforms

Upvotes: 1

Related Questions