kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robin Moffatt <ro...@confluent.io>
Subject Re: how to use SMT to transform a filed value in kafka connect?
Date Tue, 10 Jul 2018 19:20:57 GMT
ReplaceField works with fields themselves, not the values.

You could either write your own SMT to do what you want, or you could use
KStreams or KSQL to process the data in the topic once ingested through
Connect. The simplest way would be with the CASE statement
<https://github.com/confluentinc/ksql/issues/620> (
https://github.com/confluentinc/ksql/issues/620)


-- 

Robin Moffatt | Developer Advocate | robin@confluent.io | @rmoff


On Tue, 10 Jul 2018 at 03:48, 刘波 <1091643978@qq.com> wrote:

> Hi all,
> I'm new to kafak. I'm using kafka to build a ETL program.
>
>
> Here's my scinaro,
> My jdbc connect  table t_user have a column sex which is int in mysql,
> and use 0 to represent male, 1 to represent female.
>
>
> I want change sex value when 0 then 100, when 1 then 200.
>
>
> below is my connecter config:
> {
>     "name":"trans-sex",
>     "config":{
>         "connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector",
>         "connection.url":"jdbc:mysql://
> 10.4.89.214:3306/test?user=root&password=root",
>         "mode":"timestamp",
>         "table.whitelist":"t_user",
>         "validate.non.null":false,
>         "timestamp.column.name":"login_time",
>         "topic.prefix":"nobinlog.",
>
>         "transforms": "convert_sex",
>         "transforms.convert_sex.type":
> "org.apache.kafka.connect.transforms.ReplaceField$Value",
>         "transforms.convert_sex.renames": "0:100,1,200"
>
>
>     }
> }
>
>
>
> any ideas,
> thanks a lot

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message