Gerald
03/13/2023, 5:01 PMCREATE TABLE Person (
Id int,
Firstname string,
Lastname string,
DateOfBirth date,
primary key (Id) not enforced
) WITH ( ... )
CREATE TABLE Address (
Id int,
Street string,
ZipCode string,
City string,
Country string,
PersonId int,
primary key (Id) not enforced
) WITH ( ... )
It doesn't matter what gets updated (Person or Address), for both source triggers I want to emit a new combined PersonUpdate event that contains information about the person and its corresponding addresses:
CREATE TABLE PersonUpdate (
Id int,
Firstname string,
Lastname string,
DateOfBirth date,
Addresses ARRAY<ROW(Street string, City string, ZipCode string, Country string)>,
primary key (Id) not enforced
) WITH (...)
One option I read about would be to use temporal joins, having the right side of the join doing lookups on for example the Address table (getting all addresses for a specific person X). However, as far as I understood the semantics of temporal joins, the join wouldn’t trigger if there is only an update on the Address table (e.g., an address is added with PersonId X)?
This brings me to the question, whether in such cases I would need to duplicate the same query, but this time doing the temporal lookup on the Person table? But what if I need to join multiple tables to get all the enrichment info for my event? Would I need to duplicate the query multiple times and flip the join directions to set all the required triggers?
Another alternative I currently see would be to rely on the DataStream API by connecting all involved source streams, creating KeyedStreams and then do the state work on my own (e.g., in .process(...)) using ValueState or MapState etc.. Would that be a better performing or recommended solution compared to the one using temporal joins?
Or did I miss any other alternative? What I clearly want to avoid are lookup joins doing the lookup on the database again.sap1ens
03/13/2023, 5:07 PMGerald
03/13/2023, 6:10 PMsap1ens
03/13/2023, 6:12 PM