You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by "wanglei2@geekplus.com.cn" <wa...@geekplus.com.cn> on 2020/03/09 11:14:06 UTC

Kafka sink only support append mode?

I  wrote a simple program reading from kafka using  sql  and sink to kafka.
But only  'update-mode' = 'append' is supported for sink table and the query sql must have no group statement.
Only append mode is supported for kafka sink?

Thanks,
Lei



Re: Re: Kafka sink only support append mode?

Posted by Jark Wu <im...@gmail.com>.
Hi Lei,

Are you trying a regular left join query?

Non-time-based operators (e.g. regular join in your case) will emit result
when input is not complete,
the result will be updated when more inputs come in (by emitting
upsert/retract messages).
But time-based operators (e.g. windowed aggregate, interval join) can emit
final result because it will wait input to be complete (by watermark),
thus it can produce append-only stream.

Maybe you can try to update your query to interval join [1] (called
time-windowed join in docs currently) to get an append result.

Best,
Jark

[1]:
https://ci.apache.org/projects/flink/flink-docs-release-1.10/dev/table/sql/queries.html#joins


On Tue, 10 Mar 2020 at 18:41, wanglei2@geekplus.com.cn <
wanglei2@geekplus.com.cn> wrote:

> Hi Jark,
> Thanks  for the  explanation.
> The group by statement will result a not append stream.
> I have just tried a join statement and want to send the result to kafka,
> it also has the error:
>      AppendStreamTableSink requires that Table has only insert changes
> Why the join result is not appendable. It confused me.
>
> Thanks,
> Lei
>
>
> *From:* Jark Wu <im...@gmail.com>
> *Date:* 2020-03-09 19:25
> *To:* wanglei2@geekplus.com.cn
> *CC:* user <us...@flink.apache.org>
> *Subject:* Re: Kafka sink only support append mode?
> Hi Lei,
>
> Yes. Currently, Kafka sink only supports append mode. Other update mode
> (e.g. upsert mode / retract mode) is on the agenda.
> For now, you can customize a KafkaTableSink with implementing
> UpsertStreamTableSink interface, where you will get a Tuple2<Boolean, Row>
> records,
> and the Boolean represents insert or delete operation. Then you can encode
> the insert/delete operation into Kafka storage or just ignore the
> operations.
>
> Best,
> Jark
>
> On Mon, 9 Mar 2020 at 19:14, wanglei2@geekplus.com.cn <
> wanglei2@geekplus.com.cn> wrote:
>
>> I  wrote a simple program reading from kafka using  sql  and sink to
>> kafka.
>> But only  'update-mode' = 'append' is supported for sink table and the
>> query sql must have no group statement.
>> Only append mode is supported for kafka sink?
>>
>> Thanks,
>> Lei
>>
>>
>>

Re: Re: Kafka sink only support append mode?

Posted by "wanglei2@geekplus.com.cn" <wa...@geekplus.com.cn>.
Hi Jark, 
Thanks  for the  explanation.
The group by statement will result a not append stream. 
I have just tried a join statement and want to send the result to kafka, it also has the error:
     AppendStreamTableSink requires that Table has only insert changes
Why the join result is not appendable. It confused me.

Thanks,
Lei
 
From: Jark Wu
Date: 2020-03-09 19:25
To: wanglei2@geekplus.com.cn
CC: user
Subject: Re: Kafka sink only support append mode?
Hi Lei,

Yes. Currently, Kafka sink only supports append mode. Other update mode (e.g. upsert mode / retract mode) is on the agenda. 
For now, you can customize a KafkaTableSink with implementing UpsertStreamTableSink interface, where you will get a Tuple2<Boolean, Row> records, 
and the Boolean represents insert or delete operation. Then you can encode the insert/delete operation into Kafka storage or just ignore the operations. 

Best,
Jark

On Mon, 9 Mar 2020 at 19:14, wanglei2@geekplus.com.cn <wa...@geekplus.com.cn> wrote:
I  wrote a simple program reading from kafka using  sql  and sink to kafka.
But only  'update-mode' = 'append' is supported for sink table and the query sql must have no group statement.
Only append mode is supported for kafka sink?

Thanks,
Lei



Re: Kafka sink only support append mode?

Posted by Jark Wu <im...@gmail.com>.
Hi Lei,

Yes. Currently, Kafka sink only supports append mode. Other update mode
(e.g. upsert mode / retract mode) is on the agenda.
For now, you can customize a KafkaTableSink with implementing
UpsertStreamTableSink interface, where you will get a Tuple2<Boolean, Row>
records,
and the Boolean represents insert or delete operation. Then you can encode
the insert/delete operation into Kafka storage or just ignore the
operations.

Best,
Jark

On Mon, 9 Mar 2020 at 19:14, wanglei2@geekplus.com.cn <
wanglei2@geekplus.com.cn> wrote:

> I  wrote a simple program reading from kafka using  sql  and sink to kafka.
> But only  'update-mode' = 'append' is supported for sink table and the
> query sql must have no group statement.
> Only append mode is supported for kafka sink?
>
> Thanks,
> Lei
>
>
>