You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Robin Moffatt <ro...@confluent.io> on 2018/07/10 19:20:57 UTC

Re: how to use SMT to transform a filed value in kafka connect?

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, 刘波 <10...@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