pattern to detect if event field changed

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pattern to detect if event field changed

Yoandy Rodríguez
Hello,

I have a stream of events in the form (key, field1, field2) and I would
like to detect every time field2 value changes and emit a new

event on another stream.  I searched StackOverflow and [1] was the
closest to my use case but not quite since I don't have a pattern

to match.


Is it possible to express something like this using Flink?


Thanks in advance.


[1].
https://stackoverflow.com/questions/42065388/when-might-flink-support-pattern-match-involving-fields-of-previous-events


Reply | Threaded
Open this post in threaded view
|

Re: pattern to detect if event field changed

Sameer Wadkar
You could use ValueState (keyed by key) to store the event. And when each event arrives, check the value in the State to determine if either of "Field1" or "Field2" has changed. If either of the fields have changed, update the state with the new event and perform the trigger (emitting the modified event) operation. If neither has changed don't do anything (leave State alone)

On Tue, Jul 30, 2019 at 11:03 AM Yoandy Rodríguez <[hidden email]> wrote:
Hello,

I have a stream of events in the form (key, field1, field2) and I would
like to detect every time field2 value changes and emit a new

event on another stream.  I searched StackOverflow and [1] was the
closest to my use case but not quite since I don't have a pattern

to match.


Is it possible to express something like this using Flink?


Thanks in advance.


[1].
https://stackoverflow.com/questions/42065388/when-might-flink-support-pattern-match-involving-fields-of-previous-events