Late-arriving dimension
Dimension data that reaches the warehouse after the fact rows that refer to it, such as an order for a customer whose record has not loaded yet. The usual handling is a placeholder dimension row that is filled in when the real record arrives.
Also: late-arriving dimensions · early-arriving fact · inferred member
On this page · 7 sections
- Category
- Data modeling
- Also known as
- late-arriving dimensions, early-arriving fact, inferred member
- Goes deeper in
- Data Modeling
A late-arriving dimension is a timing problem between two feeds. The order stream delivers a sale for customer C-200 at noon, and the customer file that describes C-200 does not land until the nightly batch. When the fact load looks up the customer, there is no row to find. Dropping the order would understate revenue, and loading it with an empty key would break every join.
Ralph Kimball's answer is a placeholder. The load inserts a dimension row that carries the source system's identifier (the natural key) and generic values such as Unknown for everything else, and the fact row takes that row's key. When the real record arrives, the placeholder is overwritten in place, as a Type 1 change. The fact rows need no update because the key they hold has not moved. Seen from the fact side, Kimball calls the same situation an early-arriving fact.
Two related cases have similar names. A late-arriving fact is an event that reaches the warehouse well after it happened; the load must look up the dimension row that was in effect on the event date, not the current one. And a backdated correction to a Type 2 attribute, one tracked with a new row per change, needs a dimension row inserted into the past, with the affected fact rows pointed at it.
-- 1. Orders refer to a customer the dimension has not seen: add a placeholder.
insert into dim_customers (customer_id, customer_name, segment, is_placeholder)
select distinct s.customer_id, 'Unknown', 'Unknown', true
from stg_orders s
where not exists (
select 1 from dim_customers d where d.customer_id = s.customer_id
);
-- 2. Load the facts. Every order now finds a customer_key.
insert into fct_orders (order_id, customer_key, order_amount)
select s.order_id, d.customer_key, s.order_amount
from stg_orders s
join dim_customers d on d.customer_id = s.customer_id;
-- 3. The customer record arrives later: overwrite the placeholder in place.
update dim_customers
set
customer_name = (
select c.customer_name from stg_customers c
where c.customer_id = dim_customers.customer_id
),
segment = (
select c.segment from stg_customers c
where c.customer_id = dim_customers.customer_id
),
is_placeholder = false
where is_placeholder = true
and exists (
select 1 from stg_customers c
where c.customer_id = dim_customers.customer_id
);
select
d.customer_name,
count(*) as orders,
sum(f.order_amount) as revenue
from fct_orders f
join dim_customers d on d.customer_key = f.customer_key
group by d.customer_name
order by d.customer_name;Feeds from different systems do not arrive in step unless someone makes them, and streaming facts next to batch dimensions make the gap routine. A pipeline with no plan for it either loses rows on an inner join or fails a relationship test.
The placeholder keeps totals right from the first load. Revenue is complete immediately and shows under Unknown until the record lands, which is visible and honest, and it moves to the right customer without anyone reprocessing facts.
- Inner joining facts to the dimension during the load, which silently discards every row whose dimension record has not arrived.
- Mapping all unmatched rows to one shared Unknown member. The totals are right, yet the rows cannot be told apart later, so they stay under Unknown after the real records arrive unless the fact rows are updated.
- Treating the first real values as a tracked change. On a dimension with history, filling in a placeholder should overwrite it, not close the Unknown version and open a new one.
- What is the difference between a late-arriving dimension and a late-arriving fact?
- With a late-arriving dimension, the fact is on time and the descriptive record is missing, so the load creates a placeholder dimension row. With a late-arriving fact, the dimension is fine and the event shows up days or weeks after it occurred, so the load must find the dimension version that was valid on the event date instead of the latest one.
- What is an inferred member?
- It is the name Microsoft's documentation uses for the placeholder row: a dimension member created by the fact load from nothing but its source identifier, with a flag marking it as inferred. When the full record arrives, the dimension load fills in the attributes and clears the flag. It is the same idea as Kimball's placeholder row.
- How do you handle late-arriving dimensions in dbt?
- In dbt this is ordinary model logic. One pattern builds the dimension from the union of the real source and the distinct identifiers seen in the fact source, filling missing attributes with Unknown, so every fact key finds a row. A relationships test between the fact and the dimension confirms nothing was left unmatched. When the real record lands, the next run replaces the placeholder.
