According to <@U03GGB2FH8W>’s answer to this quest...
# troubleshooting
t
According to @David Anderson’s answer to this question: https://stackoverflow.com/questions/73413870/flink-sql-watermark-strategy-after-join-operation, interval joins should have watermarks. However I tried a very simple interval join:
create view test4 as(select *, current_watermark(test1.order_time) as curr, if(test1.order_time > test2.order_time, test1.order_time, test2.order_time) as mt from test1 inner join test2 on test1.product = test2.product where test1.order_time BETWEEN test2.order_time - INTERVAL '1' SECOND and test2.order_time);
and the
desc test4
showed that the view doesn't have a watermark defiined. Did I mess up somewhere?
d
I'm not sure, but perhaps the output of
desc
doesn't accurately reflect whether or not the query result includes watermarks. To know for sure, you can use the view as input to a query that requires watermarks -- e.g., try applying event time windowing to the view and see if the planner will allow it.
t
Yep I think it does 🙂 I am still a bit confused on how the watermark gets generated past a interval join. Seems to be a delay of the interval length + 1 second. Is that right @David Anderson?
d
I think what happens is this: • A watermark arrives and triggers a timer, which causes the join operator to produce results. • The operator somehow decides what timestamp to put into the resulting streamrecords. • The operator then forwards the watermark.
t
and that timer is 1 second?
d
I just looked at the code; I was wrong about how this works. The actual implementation is more complicated/clever. Haven't figured out (yet?) how the timestamping and watermarking works. (But no, it wouldn't be periodic timers -- it would be event-time timers based on the records' timestamps and the interval involved.)
t
can you point me to the code as well?
d
Look for
IntervalJoinOperator
.
t
On this topic -- how do I make sure that FlinkSQL emits window results on every record instead of only after window end?
Is it even possible to specify custom triggering strategies in FlinkSQL?
d
No, that’s not supported.
t
So I can never get results of my "current window" in my streaming program, so to speak
d
For the old-style GROUP BY windows (as opposed to the newer table-valued window functions) there’s an undocumented notion of a WindowEmitStrategy that supports allowed lateness, early firing, and late firing. For example, if you set
table.exec.emit.early-fire.delay
to 0, then all windows will be triggered on every element.
This feature has been around for quite a long time, but is experimental and feels a bit hacky.
t
This can be a SQL config?
d
I think so. Set it on the cluster running the query.
You may also need to set
table.exec.emit.early-fire.enabled: true
to get this working.
t
org.apache.flink.table.api.TableException: Session window doesn't support EMIT strategy currently.
I suppose it is not supported for session windows then
do you think that's right?
d
Yes, I noticed that restriction in the code.
t
What will be the result of this sorted by?
It seems like the behavior is rather non-deterministic. Sometimes I see it is being sorted on test2's timestamp, sometimes on test1
d
That doesn't surprise me. Many of the SQL operators behave non-deterministically (or in undefined ways), when the "correct" behavior is weakly defined.