Hey everyone, basic data engineering question:
Would anyone know how to translate a type 2 warehouse table (1 entry has an array of historical values with a "changed at") into a monthly value with the actual value at that time? I'm trying to wrap my head around it with SQL
a
aaronsteers
09/07/2022, 6:29 PM
There are two methods really:
1. Date join calendar date between the start and end date of the dim.
2. Surrogate key join, which is often the same as above in how the key is created and populated to the fact table, but then when you join from dim to fact, it's an equijoin (faster and safer than a range join at runtime).
aaronsteers
09/07/2022, 6:31 PM
I like to create surrogate keys as a concatenation of the business key and the start date as a stringified int with a delimiter. This makes for a deterministic key that's meaningful for humans and easy to debug.
aaronsteers
09/07/2022, 6:32 PM
Probably others have approaches which work well for them, but that's generally my approach personally.
s
Stéphane Burwash
09/07/2022, 6:35 PM
Awesome, thank you so much! I'll have to look up how to operate them both