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

Bug Fix: Date spine timestamp error #24

Merged
merged 9 commits into from
Aug 1, 2024

Conversation

fivetran-avinash
Copy link
Contributor

@fivetran-avinash fivetran-avinash commented Jul 30, 2024

PR Overview

This PR will address the following Issue/Feature: [#23]

This PR will result in the following new package version: 0.5.0

No fields were changed in this update, just the behavior of the spine for empty general ledger models.

Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:

Bug Fixes

  • Updated the int_sage_intacct__general_ledger_date_spine model to accommodate for the cases when the compiled sage_intacct__general_ledger model has no transactions. In this case, the model now defaults to a range of one-month from the current date.

Under The Hood

  • Updated the structure of the int_sage_intacct__general_ledger_date_spine model for improved performance and maintainability.
  • Added flags.WHICH in ('run', 'build') as a condition in int_sage_intacct__general_ledger_date_spine to prevent call statements from querying the staging models during a dbt compile.
  • Addition of integrity and consistency validation tests within integration tests for the sage_intacct__general_ledger and sage_intacct__general_ledger_by_period model.

PR Checklist

Basic Validation

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

  • dbt run –full-refresh && dbt test
  • [NA] dbt run (if incremental models are present)

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

  • The appropriate issue has been linked, tagged, and properly assigned.
  • [NA] All necessary documentation and version upgrades have been applied.
  • docs were regenerated (unless this PR does not include any code or yml updates).
  • BuildKite integration tests are passing.
  • Detailed validation steps have been provided below.

Detailed Validation

Please share any and all of your validation steps:

To reproduce the error, I created empty versions of the seed files that flowed into the general ledger model, in this case gl_account, gl_batch and gl_detail, then ran it in snowflake.

Screenshot 2024-07-29 at 8 59 46 PM

Adding the new logic fixed the error on a dbt run.

Also updating the date spine model to match our recent salesforce updates led to a successful dbt compile.
Screenshot 2024-07-26 at 2 20 39 PM

To validate these changes on devprod, I created:

  • An integrity test that compared row counts to the general_ledger_by_period model that flows downstream from the new general_ledger_date_spine.
  • I created a consistency test for the general_ledger to compare values between dev and prod.
Screenshot 2024-07-29 at 8 04 19 PM

One note:

  • I originally created a consistency test on the general_ledger_by_period as well, but this test was failing. It appears the old logic uses the current date as the last date. So prod takes a lot of extra records that probably shouldn't exist since the max(entry_date_at) that created the max date on prod and dev is almost a year old.
Screenshot 2024-07-30 at 12 29 06 AM

So this test should fail on this PR, but should work for all future PRs. I've left it in here with the expectation that it'll fail here but is a useful test for future models.

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

🦴

@fivetran-avinash fivetran-avinash self-assigned this Jul 30, 2024
@fivetran-avinash fivetran-avinash linked an issue Jul 30, 2024 that may be closed by this pull request
4 tasks
@fivetran-avinash fivetran-avinash changed the title Bug Fix: Date spine timestamp Error Bug Fix: Date spine timestamp error Jul 30, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

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

Looks good just reminder to set it as a breaking change!

Copy link
Contributor

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

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

@fivetran-avinash thanks for your work on this PR. It's looking great, I just have a few small notes before approval. Let me know if you want to sync on any of my notes.

CHANGELOG.md Outdated
## 🚨 Breaking Changes: Bug Fixes 🚨
- Updated the structure of the `int_sage_intacct__general_ledger_date_spine` model for improved performance and maintainability.
- Modified the date spine logic so that the model will take the maximum `entry_date_at` from the `sage_intacct__general_ledger` for the last date of the spine if it is available, rather than the current date. This will help capture future-dated transactions as well beyond the current date.
- This is a breaking change, as this will change what transaction records of `sage_intacct__general_ledger_by_period` end up in our final models.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would adjust the wording of this sub bullet as it reads a bit confusing. We are saying the records will change but then don't directly reference what exactly is changing. It sounds like we are being selective as to which transaction records will be included in the final model. We are not limiting the transactions but instead changing the behavior of the date spine. Ultimately we are providing a more accurate representation of their transactions and this may adjust the records in their end model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@fivetran-avinash
Copy link
Contributor Author

@fivetran-avinash thanks for your work on this PR. It's looking great, I just have a few small notes before approval. Let me know if you want to sync on any of my notes.

@fivetran-joemarkiewicz This is ready for re-review.

Copy link
Collaborator

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

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

LGTM

@fivetran-avinash fivetran-avinash merged commit b77ddf2 into main Aug 1, 2024
8 checks passed
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] Timestamp not recognized error when generating datespine
3 participants