Skip to content
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

Bugfix/join on source relation #95

Merged
merged 20 commits into from
Jul 12, 2023

Conversation

fivetran-catfritz
Copy link
Contributor

@fivetran-catfritz fivetran-catfritz commented Jul 3, 2023

PR Overview

This PR will address the following Issue/Feature:

This PR will result in the following new package version:

  • 11.0 - Could use input on this. On the one hand no changes for most users, but on the other hand this could affect row counts for users using union feature. I chose to err on the side of caution but open to suggestions.

Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:

  • Adds source_relation to appropriate joins, window function partitions, and window function order bys.

PR Checklist

Basic Validation

Please acknowledge that you have successfully performed the following commands locally:

Before marking this PR as "ready for review" the following have been applied:

  • The appropriate issue has been linked and tagged
  • You are assigned to the corresponding issue and this PR
  • BuildKite integration tests are passing

Detailed Validation

Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":

  • You have validated these changes and assure this PR will address the respective Issue/Feature.
  • You are reasonably confident these changes will not impact any other components of this package or any dependent packages.
  • You have provided details below around the validation steps performed to gain confidence in these changes.
  • See workbook linked in ticket.

Standard Updates

Please acknowledge that your PR contains the following standard updates:

  • Package versioning has been appropriately indexed in the following locations:
    • indexed within dbt_project.yml
    • indexed within integration_tests/dbt_project.yml
  • CHANGELOG has individual entries for each respective change in this PR
  • README updates have been applied (if applicable)
  • DECISIONLOG updates have been updated (if applicable)
  • Appropriate yml documentation has been added (if applicable)

dbt Docs

Please acknowledge that after the above were all completed the below were applied to your branch:

  • docs were regenerated (unless this PR does not include any code or yml updates)

If you had to summarize this PR in an emoji, which would it be?

💃

@fivetran-catfritz fivetran-catfritz self-assigned this Jul 3, 2023
columns:
- name: unique_id
description: Unique identifier of the general ledger line, dependent on `transaction_id`, `transaction_index`, `account_id`, `transaction_type`, `transaction_source`.
description: >
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call that the above test is redundant.

Copy link
Contributor

@fivetran-avinash fivetran-avinash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mostly good to go! Just need to update the CHANGELOG --it is definitely a breaking change, good intuition!

- Included `source_relation` in all joins and window functions for models outputting `source_relation`. This is to prevent duplicate records in end models when using the unioning functionality. These updates were in the intermediate models, which flowed to downstream end models:
- `quickbooks__general_ledger`
- `quickbooks__expenses_sales_enhanced`
- In end model `quickbooks__general_ledger`, added `source_relation` as part of the generated surrogate key `unique_id` to prevent duplicate `unique_id`s when using the unioning functionality.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the surrogate key in an end model is a breaking change, so you can highlight that as the top section.

Also the standard "We recommend using dbt run --full-refresh the next time you run your project."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Updated!

@@ -1,3 +1,18 @@
# dbt_quickbooks v0.11.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

🚨 Breaking Changes 🚨 (recommend --full-refresh)

with the surrogate key line below on Line 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

packages.yml Outdated
# - package: fivetran/quickbooks_source
# version: [">=0.9.0", "<0.10.0"]

- git: https://github.com/fivetran/dbt_quickbooks_source.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard reminder to revert

- In end model `quickbooks__general_ledger`, added `source_relation` as part of the generated surrogate key `unique_id` to prevent duplicate `unique_id`s when using the unioning functionality.

## 🚘 Under the Hood
- Updated test from a combination of columns to uniqueness of `unique_id` in `quickbooks__general_ledger`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add a small note about the ordering in the cash flow statement, just to keep raising awareness for it since it's a relatively new feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Updated.

coalesce(lag(cash_ending_period) over (partition by account_id, class_id, source_relation order by cash_flow_period),0) as cash_beginning_period,
cash_ending_period - coalesce(lag(cash_ending_period) over (partition by account_id, class_id, source_relation order by cash_flow_period), 0) as cash_net_period
coalesce(lag(cash_ending_period) over (partition by account_id, class_id, source_relation
order by source_relation, cash_flow_period),0) as cash_beginning_period,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch to order it by source relation, missed this when I did it.

@fivetran-catfritz fivetran-catfritz merged commit 5fe28a4 into main Jul 12, 2023
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.

[Bug] Duplicates in double entry models when using multiple Quickbooks connectors
2 participants