@@ -48,11 +48,14 @@ public abstract class AbstractFlinkCompiler implements Compiler<DataStream<?>> {
48
48
protected final StreamExecutionEnvironment env ;
49
49
protected final StreamTableEnvironment tableEnv ;
50
50
protected final Duration allowedLatency ;
51
+ protected final Duration withIdleness ;
51
52
52
- public AbstractFlinkCompiler (StreamExecutionEnvironment env , StreamTableEnvironment tableEnv , Duration allowedLatency ) {
53
+ public AbstractFlinkCompiler (StreamExecutionEnvironment env , StreamTableEnvironment tableEnv , Duration allowedLatency ,
54
+ Duration withIdleness ) {
53
55
this .env = env ;
54
56
this .tableEnv = tableEnv ;
55
57
this .allowedLatency = allowedLatency ;
58
+ this .withIdleness = withIdleness ;
56
59
Utils .registerFunctions (this .tableEnv );
57
60
}
58
61
@@ -95,7 +98,7 @@ protected <K, T, U> KeyedStream<Tuple2<Long, Pair<K, Pair<T, U>>>, K> compileLef
95
98
96
99
final LeftJoinPairMonoid <T , U > m = new LeftJoinPairMonoid <>();
97
100
DataStream <Tuple2 <Long , Pair <K , Pair <T , U >>>> ss = ks2 .map (x -> new Tuple2 <>(x .f0 , new Pair <>(x .f1 .l , new Pair <T , U >(null , x .f1 .r ))), outputType ).union (ks1 .map (x -> new Tuple2 <>(x .f0 , new Pair <>(x .f1 .l , new Pair <T , U >(x .f1 .r , null ))), outputType ));
98
- return ss .assignTimestampsAndWatermarks (Utils .watermark (isBatch (), Duration .ZERO )).keyBy (t -> t .f1 .l , kType )
101
+ return ss .assignTimestampsAndWatermarks (Utils .watermark (isBatch (), Duration .ZERO , Duration . ofMillis ( 300 ) )).keyBy (t -> t .f1 .l , kType )
99
102
// a window to make sure if we have multiple events happening
100
103
// at the same time, U is always put before T in batch mode
101
104
.window (TumblingEventTimeWindows .of (Time .days (1 ))).allowedLateness (Time .days (1 )).process (new ProcessWindowFunction <Tuple2 <Long , Pair <K , Pair <T , U >>>, Tuple2 <Long , Pair <K , Pair <T , U >>>, K , TimeWindow >() {
@@ -179,7 +182,8 @@ protected <K, T> KeyedStream<Tuple2<Long, Pair<K, T>>, K> compileOrderedSum(Orde
179
182
}
180
183
181
184
protected <T > DataStream <Tuple2 <Long , T >> compileConcat (ConcatStream <T > stream ) {
182
- return compile (stream .a ).union (compile (stream .b )).assignTimestampsAndWatermarks (Utils .watermark (isBatch (), this .allowedLatency ));
185
+ return compile (stream .a ).union (compile (stream .b ))
186
+ .assignTimestampsAndWatermarks (Utils .watermark (isBatch (), this .allowedLatency , this .withIdleness ));
183
187
}
184
188
185
189
protected <T > DataStream <Tuple2 <Long , T >> compileFilter (FilterStream <T > stream ) {
@@ -192,7 +196,7 @@ protected <T, U> DataStream<Tuple2<Long, U>> compileSql(final SqlStream<T, U> st
192
196
final var typeInfo = stream .typeInfo ;
193
197
return tableEnv .toAppendStream (table , Row .class ).map (r -> new Tuple2 <>((Long ) r .getField (0 ), mapper .map (r )), typeInfo )
194
198
// watermark and timestamp is lost after table to data stream conversion?
195
- .assignTimestampsAndWatermarks (Utils .watermark (isBatch (), this .allowedLatency ));
199
+ .assignTimestampsAndWatermarks (Utils .watermark (isBatch (), this .allowedLatency , this . withIdleness ));
196
200
}
197
201
198
202
protected <K , T > KeyedStream <Tuple2 <Long , Pair <K , T >>, K > compileKS (KStream <K , T > ks ) {
0 commit comments