+1 for unifying the behavior of AppendingState#add . However, I have concern for the usage of window reducing function [1], I'm not sure whether user would rely on processing StreamRecord(null) to clear state. As you can see, user could not see the reducing window state directly, and the only way to communicate with state is via processing records.
I'm not sure whether this is by design, @Aljoscha Krettek<mailto:aljos...@apache.org> would you please share the initial idea when introducing this for the first time? [1] https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/operators/windows.html#reducefunction Best Yun Tang ________________________________ From: Yu Li <car...@gmail.com> Sent: Thursday, January 9, 2020 14:09 To: dev <dev@flink.apache.org> Subject: Re: [DISCUSS] Make AppendingState#add refuse to add null element +1 for unifying the behavior to refusing adding null element. Nice catch and thanks for bringing up the discussion! Best Regards, Yu On Wed, 8 Jan 2020 at 22:50, Aljoscha Krettek <aljos...@apache.org> wrote: > Hi, > > As I said in the discussion on the Jira issue, I’m in favour of this > change! > > This is the Jira Issue, for reference: > https://issues.apache.org/jira/browse/FLINK-15424 > > Best, > Aljoscha > > > On 8. Jan 2020, at 15:16, Congxian Qiu <qcx978132...@gmail.com> wrote: > > > > Dear All > > > > > > Currently, we found the implementations of AppendingState#add are not the > > same, taking some as example: > > > > - HeapReducingState will clear state if add null element > > - RocksDBReducingState will add null element if serializer can > serialize > > null > > - Both HeapListState and RocksDBListState refuse to add null element — > > will throw NullPointException > > > > > > we think this need to be fixed, and possible solutions include: > > > > 1. Respect the current java doc, which said “If null is passed in, the > > state value will remain unchanged” > > 2. Make all AppendingState#add refuse to add null element > > > > > > We propose to apply the second solution, following the recommendation in > > Guava[1]. > > > > > > Would love to hear your thoughts. Thanks. > > > > > > Regards, > > > > Congxian > > > > > > [1] https://github.com/google/guava/wiki/UsingAndAvoidingNullExplained > >