-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Duplicate rows in int_quickbooks__invoice_join.sql
model when more than one QuickBooks source
#120
Comments
Thanks @MatteyRitch for opening this and including all the details! I'm seeing what you're talking about. I think these lines need to include a join on the source_relation: dbt_quickbooks/models/intermediate/int_quickbooks__invoice_join.sql Lines 122 to 123 in eb968fb
dbt_quickbooks/models/intermediate/int_quickbooks__invoice_join.sql Lines 72 to 76 in eb968fb
In addition to the ones you mentioned:
I will circle this back with the team and keep you updated. |
My pleasure & thank you for the quick response @fivetran-reneeli! Yes I agree with what you wrote, though the main branch already had the source_relation joins on the estimates , payments, and payment_lines_payment joins in the dbt_quickbooks/models/intermediate/int_quickbooks__invoice_join.sql Lines 113 to 115 in eb968fb
dbt_quickbooks/models/intermediate/int_quickbooks__invoice_join.sql Lines 118 to 120 in eb968fb
dbt_quickbooks/models/intermediate/int_quickbooks__invoice_join.sql Lines 122 to 125 in eb968fb
Here is where / what I think needs to be modified: dbt_quickbooks/models/intermediate/int_quickbooks__invoice_join.sql Lines 38 to 77 in eb968fb
Changed above to this:
Hopefully that is clear & I'll look out for your reply. |
I thought I included this in the above post. The additions to the code are the |
Thanks for following up and yup I agree with you there! We'll also need to add joins on source_relation in all the invoice ID joines in the intermediate CTEs, leading up to the final CTE, to prevent fan outs in the event of same invoice id's across different sources. I will check for missing joins in the other models as well. Again, appreciate the details you left; I will file this into our upcoming sprints! |
I've went through and noted where else the joins are needed on source relation to prevent fan outs below. @MatteyRitch I know you mentioned you were up for opening a PR so we welcome that, otherwise also we'll be adding this to our upcoming sprint! GitHub - dbt_quickbooks/models/intermediate/int_q… GitHub - dbt_quickbooks/models/intermediate/int_q… GitHub - dbt_quickbooks/models/intermediate/int_q… GitHub - dbt_quickbooks/models/intermediate/int_q… GitHub - dbt_quickbooks/models/intermediate/int_q… GitHub - dbt_quickbooks/analysis/quickbooks__bala… GitHub - dbt_quickbooks/analysis/quickbooks__bala… GitHub - dbt_quickbooks/analysis/quickbooks__bala… |
Hi @fivetran-reneeli - sorry I was out on Monday. I just opened the PR . I wasn't aware of the need to update the changelog and versions prior to the first commit so I had to tack a 2nd one on - sorry. One note, I couldn't find where the source_relation join / fields were needed in this model. They seem to already be there: dbt_quickbooks/models/intermediate/int_quickbooks__bill_join.sql Lines 87 to 89 in eb968fb
|
Thanks for the PR @MatteyRitch! No worries, and we will also make some additional updates on top of your PR to make sure everything is good to go before merging it in. We aim to have this merged in the coming weeks! |
fixes #120 - missing source_relation joins
Hi @MatteyRitch , just finalized our PR and added some final touches. Could you confirm this works on your data? packages.yml
|
Is there an existing issue for this?
Describe the issue
Pulling from the int_quickbooks__invoice_join model can return duplicate payments (different payment_ids based on the source) for the same invoice.
The CTEs aliased as "invoice_est" and "invoice_pay" bring in the invoice_id and payment_id and join only on invoice_id.
If the same invoice_id exists in multiple quickbooks sources, there will be a cross join that causes duplicate entries in these CTE results which is then propagated when they are used downstream.
Relevant error log or model output
No response
Expected behavior
Only have payments that were associated with a given invoice returned.
dbt Project configurations
Package versions
What database are you using dbt with?
postgres
dbt Version
Additional Context
No response
Are you willing to open a PR to help address this issue?
The text was updated successfully, but these errors were encountered: