Skip to content

Fix: Remove duplicate rows in agg_monthly_loans#9

Open
jjoyce0510 wants to merge 1 commit intomainfrom
fix/agg-monthly-loans-duplication
Open

Fix: Remove duplicate rows in agg_monthly_loans#9
jjoyce0510 wants to merge 1 commit intomainfrom
fix/agg-monthly-loans-duplication

Conversation

@jjoyce0510
Copy link

Problem

The Risk Analytics Reporting Dashboard is showing inflated loan values this month. The agg_monthly_loans model has a bug introduced in commit sofritoguy/Add customer_id to monthly loan aggregations that creates duplicate rows.

Root Cause

A LEFT JOIN on loan_type_name between the monthly originations and loans table creates one row per customer per loan type, multiplying the loan amounts. For example, Mortgage loans in February show $54M instead of $27M (doubled due to duplication).

Solution

  • Remove the problematic LEFT JOIN to the loans table
  • Remove the customer_id column that was causing the duplication
  • Restore correct aggregation logic with distinct loan_id counts

Impact

  • Fixes the Risk Analytics Reporting Dashboard to show correct loan values
  • Resolves the failing row count assertion on agg_monthly_loans
  • Restores accurate monthly loan metrics by type

Testing

After merge, run dbt test to verify:

  • Row count assertion passes (should be ~76 rows, not 1,162)
  • Loan amount values match previous months' patterns

…EFT JOIN

The LEFT JOIN to loans table on loan_type_name was creating duplicate rows,
inflating loan values in the Risk Analytics Reporting Dashboard. This commit:

- Removes the problematic LEFT JOIN to the loans table
- Removes the customer_id column that was causing duplication
- Restores correct aggregation logic with distinct loan_id counts
- Fixes the row count assertion that was failing due to duplicates

The monthly aggregations now correctly calculate loan metrics by month and type
without multiplying values across multiple customers.
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