You wrote a SELECT, expected 1,000 rows, and got 4,800. The numbers in your dashboard suddenly doubled. Welcome to one of the most common SQL bugs in the world: an accidental fan-out join.
The four causes, in order of frequency
- Joining a one-to-many child table without aggregating it first.
- Joining two child tables that both fan out from the same parent.
- A LEFT JOIN with a non-unique key on the right side.
- A self-join on a non-unique column (often a name or email).
How lineage helps
Once you have the column-level lineage of the broken view in front of you, the fix is usually obvious: the column whose count exploded is sourced from a table that should have been pre-aggregated. Look at which join the offending column flows through, and you have your answer.
-- Wrong: order_items fans out per order
SELECT o.order_id, SUM(i.amount) AS revenue, p.discount_amount
FROM orders o
JOIN order_items i ON i.order_id = o.order_id
JOIN promotions p ON p.order_id = o.order_id -- second fan-out!
GROUP BY o.order_id, p.discount_amount;Pre-aggregate one side before joining the other, or use a window function. The lineage graph makes the second fan-out impossible to miss — both joined tables show as feeding the same downstream sum.
Try it on your own SQL
Paste the offending view into the playground. Click on the SUM column in the lineage panel. The two source tables it depends on will light up — that is your fan-out.