Hi, sorry for late reply - busy days
Yes, I do believe custom materializations is the way to go, as the actual loading pattern is given, and with a minimum of configuration (business keys, columns selected for hash_diff for satellites, etc), together with the dependency tracking built-in to dbt, I think we have a winner.
- By the end of the day, materializations are j"just" a set of macros too when you think about it.
I got side-tracked this last week with building a package for the metrics mart (dv-metrics, close to version 1.0, I think another week and it should be ready at least for the raw vault - still need to work a bit on how to handle bridges. pit tables are easy though), but once that is done Iāll continue on my materialization package.
when you say PK, are we talking physical/actual PKās, or do you pass the column(s) as part of the config?
the way I see it is kind of like this:
you have a landing zone/extract table like this (pseudo example):
create table stage_.customer_list
(
customer_number varchar(128),
country_code varchar(128),
city varchar(128),
load_dts,
load_src
)
from this we build base models (base__customer_list), materialized as views:
select
customer_number,
country_code,
city,
load_dts,
load_src
from stage_.customer_list
on top of this we can now build:
-hubs:
h_customer.sql
{{ config(materialized=āhubā, business_key=ācustomer_numberā) }}
ref {{ref(ābase_customer_listā)}}
h_country.sql
{{ config(materialized=āhubā, business_key=ācountry_codeā) }}
select
ref {{ref(ābase_customer_listā)}}
Links:
l_customer_country.sql
{{ config(materialized=ālinkā, historization=ātrueā, hubs=[āh_customerā, āh_countryā]) }}
select X
from ref {{ref(ābase_customer_listā)}}
s_customer.sql
{{ config(materialized=āsatelliteā, historization=ātrueā, parent=āh_customerā) }}
select
{{ business_key_hash }},
city,
{{ vault_meta_columns }}
from ref {{ref(ābase_customer_listā)}}
having dived through existing materializations and tracing what dbt does, there is no question in my mind that it is the way to go. The difficult part is two-fold: figuring out a sane level of config/convention/customization, as well as ensuring cross platform (I focus on postgres for now).
Again, Iād love to see what youāve done so far, if youāre able to share the code somewhere Iād be happy to look at it, test it out, and give you some feedback.
once my dv-metrics is done, Iāll let you know, and Iād very much like to get your feedback as well
Regards,
Fridthjof-G