Hello, I've a question about left interval joins i...
# troubleshooting
m
Hello, I've a question about left interval joins in Flink SQL. We can use these to take every event from one stream, and to add data in from a second if there's a join within a time window. What I've learned is that left joins are possible - but only using undocumented syntax. In the Flink docs, interval join has syntax
Copy code
SELECT *
FROM Orders o, Shipments s
WHERE o.id = s.order_id
AND o.order_time BETWEEN s.ship_time - INTERVAL '4' HOUR AND s.ship_time
the word
JOIN
does not appear - so there's nowhere to say
LEFT JOIN
. This syntax allows for inner joins only. In Ververica's Cookbook we see syntax of the form,
Copy code
SELECT [params]
FROM orders o
JOIN shipments s ON o.id = s.order_id
WHERE 
    o.order_time BETWEEN s.shipment_time - INTERVAL '3' DAY AND s.shipment_time;
but changing
JOIN
to
LEFT JOIN
does nothing - you still get an inner join. The only place I've found working syntax is in this post to the user mailing list from 2021 where we find the form,
Copy code
SELECT [params] 
  FROM abandoned_visits av
  FULL OUTER JOIN orders o
  ON  av.key1 = o.key1
  AND av.email = o.email
  AND o.ts BETWEEN av.ts - INTERVAL '30' MINUTE AND av.ts + INTERVAL '30' MINUTE
This form,
[JOIN] ON [condition] AND [condition...] AND [time condition]
is the only form that works - you can change
FULL OUTER
to
LEFT
and get correct left join behaviour. My questions are, Should left interval join be possible in Flink SQL? Is it supported? Is it an oversight that the docs leave the reader unable to left, right or outer interval join? Many thanks in advance!
d
@Mark Nuttall these are great questions. @Jark Wu what do you think?