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

Replace dbt.current_timestamp and support timestamp casting #20

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

fivetran-avinash
Copy link
Contributor

@fivetran-avinash fivetran-avinash commented Feb 11, 2025

PR Overview

This PR will address the following Issue/Feature: Internal ticket

This PR will result in the following new package version: v0.3.2

Updating casting macros here.

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

Bug Fixes (originating within the upstream zuora_source package):

  • Leveraged the {{ dbt.type_timestamp() }} macro within staging models for all timestamp fields. Certain Redshift warehouses sync these fields as timestamp with time zone fields by default, causing errors in the zuora package. This macro safely removes timezone values from the UTC timestamps and ensures successful compilations of these models.
  • For more details, please refer to the relevant dbt_zuora_source v0.2.2 release.

Under the Hood

  • Replaced the deprecated dbt.current_timestamp_backcompat() function with dbt.current_timestamp() to ensure all timestamps are captured in UTC. (#20)

Documentation

  • Added Quickstart model counts to README. (#19)
  • Corrected references to connectors and connections in the README. (#19)

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) && dbt test

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

  • [NA] The appropriate issue has been linked, tagged, and properly assigned
  • 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:

Screenshot 2025-02-10 at 7 56 45 PM

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

⏲️

@fivetran-avinash fivetran-avinash self-assigned this Feb 11, 2025
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 a few questions and change requests before approval.

@@ -17,7 +17,7 @@ with spine as (
{# If only compiling, creates range going back 1 year #}
{% else %}
{% set calc_first_date = dbt.dateadd("year", "-1", "current_date") %}
{% set calc_last_date = dbt.current_timestamp_backcompat() %}
{% set calc_last_date = dbt.current_timestamp() %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessary for this update - but may as well create a FR to update the if execute of this date_spine to emulate the flags.which approach we've been taking in recent models.

This update can be applied in the next breaking change, but I'd like to record the need for that now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Reminder to open a FR to address this in a future breaking change. Thanks!

Copy link
Contributor Author

@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.

@fivetran-joemarkiewicz This is ready for re-review. Let me know if you are still seeing the compilation error.

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 these updates - this looks ready for pre-release!

@@ -17,7 +17,7 @@ with spine as (
{# If only compiling, creates range going back 1 year #}
{% else %}
{% set calc_first_date = dbt.dateadd("year", "-1", "current_date") %}
{% set calc_last_date = dbt.current_timestamp_backcompat() %}
{% set calc_last_date = dbt.current_timestamp() %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reminder to open a FR to address this in a future breaking change. Thanks!

packages.yml Outdated
Comment on lines 2 to 6
# - package: fivetran/zuora_source
# version: 0.2.2-a1
- git: https://github.com/fivetran/dbt_zuora_source.git
revision: bugfix/timestamp-casting
warn-unpinned: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reminder to swap before pre-release

Comment on lines +96 to +97
cast(subscriptions.subscription_start_date as {{ dbt.type_timestamp() }}) as subscription_period_started_at,
cast(subscriptions.subscription_end_date as {{ dbt.type_timestamp() }}) as subscription_period_ended_at,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks to be resolved in dev! I still see the error in prod, but this may have been an error previously that we're able to address with this change. Thanks!

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.

2 participants