Hi everyone,
I have an important question regarding the load_date in Data Vault hubs.
In my implementation, hubs are created using a standard macro with an insert-only incremental approach, meaning that existing records are never updated.
{% macro build_hub(
source_model,
business_key,
hub_hash_key,
record_source
) %}
WITH source_data AS (
SELECT
{{ dv_hash([business_key], hub_hash_key) }},
{{ business_key }},
DOP AS load_date,
'{{ record_source }}' AS record_source
FROM {{ source_model }}
WHERE DOP IS NOT NULL
AND {{ business_key }} IS NOT NULL
)
SELECT DISTINCT
{{ hub_hash_key }},
{{ business_key }},
load_date,
record_source
FROM source_data
{% if is_incremental() %}
WHERE {{ hub_hash_key }} NOT IN (
SELECT {{ hub_hash_key }} FROM {{ this }}
)
{% endif %}
{% endmacro %}
The load_date is currently populated from the source column DOP (Date of Operation). However, DOP can change when additional operations are performed on the same business entity.
After a few days, I noticed that I have records in the hub with the same entity_hash_key, entity_id, and source_system, but with different load_date values.
My questions are:
- Is this changing
DOPinformation something that should instead be stored in satellites? - Should I use
MIN(DOP)when loading the hub so that only the earliest date is stored and never changed for the same hash key, business key, and source system? - More generally, what is considered the best practice for handling
load_datein Data Vault hubs when the source operational date can change over time?
Any guidance would be greatly appreciated.