Fix: Remove duplicate rows in agg_monthly_loans#9
Open
jjoyce0510 wants to merge 1 commit intomainfrom
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Risk Analytics Reporting Dashboard is showing inflated loan values this month. The
agg_monthly_loansmodel has a bug introduced in commitsofritoguy/Add customer_id to monthly loan aggregationsthat creates duplicate rows.Root Cause
A LEFT JOIN on
loan_type_namebetween 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
Impact
Testing
After merge, run
dbt testto verify: