Huib
07/25/2023, 7:03 PM{
'A_event_ts`: '2023-07-25T00:00:00',
'B_event_ts': '2023-07-24T00:00:00',
'A_value': 12,
'B_value': 13
}
when A arrives after B, or something like:
{
'A_event_ts`: '2023-07-25T00:00:00',
'B_event_ts': '2023-07-26T00:00:00',
'A_value': 12,
'B_value': 14
}
when B arrives after A.
In effect, it’s a union of two asof joins, but that doesn’t work because the schemas become incompatible due to the definition of the system time. Any hints?
To make the question a bit more challenging, I’d like to achieve it with Flink SQL only, if possible :)sap1ens
07/25/2023, 7:07 PMWrapper(Option[A], Option[B])Huib
07/25/2023, 7:07 PMsap1ens
07/25/2023, 7:08 PMHuib
07/25/2023, 7:09 PMHuib
07/25/2023, 7:23 PMselect
A.`id` as `id`,
A.event_ts as A_event_ts,
A.`value` as A_value,
B.event_ts as B_event_ts,
B.value as B_value
FROM A
LEFT JOIN B FOR SYSTEM TIME AS OF A.event_TS
ON A.id = B.id
UNION ALL
select
B.`id` as `id,
A.event_ts as A_event_ts,
A.`value` as A_value,
B.event_ts as B_event_ts,
B.value as B_value
FROM B
LEFT JOIN A FOR SYSTEM TIME AS OF A.event_TS
ON A.id = B.idHuib
07/25/2023, 7:39 PM