Skip to content

Fix: Remove join fan-out bug in agg_monthly_loans#13

Open
bmiller-dh wants to merge 1 commit intomainfrom
fix/remove-loan-join-fanout
Open

Fix: Remove join fan-out bug in agg_monthly_loans#13
bmiller-dh wants to merge 1 commit intomainfrom
fix/remove-loan-join-fanout

Conversation

@bmiller-dh
Copy link

Problem

The Risk Analytics Reporting Dashboard is showing inflated loan values this month. The agg_monthly_loans model contains a join fan-out bug that's causing aggregated loan amounts to be multiplied incorrectly.

Root Cause

The model joins the aggregated monthly_originations CTE back to the loans table using only loan_type_name:

left join loans
    on orig.loan_type_name = loans.loan_type_name

Since monthly_originations is aggregated by month and loan_type, but the loans table contains multiple individual loan records per loan_type, this creates a Cartesian product. Each aggregated row gets multiplied by the number of loans matching that loan_type.

Example: If you have 100 loans of type "Mortgage" and the aggregated row shows $5M originated, the join multiplies this by 100, showing $500M instead.

Solution

Remove the problematic left join loans clause. The customer_id field that was added in the previous commit is not needed for the aggregation and was causing the data quality issue.

Impact

  • Fixes the inflated amount_originated values in the Risk Analytics Reporting Dashboard
  • Restores accurate monthly loan origination reporting
  • Removes unnecessary join operation, improving query performance

Testing

After merge, please run a dbt test to verify the aggregated values match expected ranges for previous months.

Removes the problematic left join on loans table that was causing
aggregated loan amounts to be multiplied by the number of loans per
loan_type. This join was creating a Cartesian product that inflated
the amount_originated values.

The customer_id field was not being used in the aggregation and was
causing the data quality issue reported in the Risk Analytics
Reporting Dashboard.

Fixes the issue introduced in commit f9d33f8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant