Skip to content

Commit

Permalink
ensure successful compile with built-in default in date_spine for non…
Browse files Browse the repository at this point in the history
… dbt runs/builds (#105)

* ensure successful compile with built-in default in date_spine for non dbt run/build

* date spine updates and changelog

* docs

* updates to date spine to ensure successful compile and runs

* unintentionally removed the date casts at the end so reverting it

* remove unnecessary else stmt, swap current timestamp backcompat to just current timestamp

* docs

* add pr link

* Update CHANGELOG.md

Co-authored-by: Avinash Kunnath <[email protected]>

* add mention of deprecating current_timestamp backcompat

* schema

* schema

---------

Co-authored-by: Avinash Kunnath <[email protected]>
  • Loading branch information
fivetran-reneeli and fivetran-avinash authored Feb 25, 2025
1 parent ec24e58 commit d860667
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# dbt_stripe v0.16.1
[PR #105](https://github.com/fivetran/dbt_stripe/pull/105) includes the following updates:

## Bug Fix
Updated the `int_stripe__date_spine` to accommodate non `dbt run` or `dbt build` commands by leveraging default dates in order to ensure successful compilation.

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

# dbt_stripe v0.16.0
## Breaking Change - Potential Change in Values May Impact Downstream Queries
- The aggregated net, gross, sale, charge, refund, and fee amount-based fields in `stripe__daily_overview` and `stripe__customer_overview` now reflect the raw smallest units (e.g., cents), following Stripe's raw data, instead of converted dollar amounts. This change standardizes values across all models.
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2
name: 'stripe'

version: '0.16.0'
version: '0.16.1'
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
stripe:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: stripe_integrations_tests_19
schema: stripe_integrations_tests_22
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: stripe_integrations_tests_19
schema: stripe_integrations_tests_22
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: stripe_integrations_tests_19
schema: stripe_integrations_tests_22
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: stripe_integrations_tests_19
schema: stripe_integrations_tests_22
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: stripe_integrations_tests_19
schema: stripe_integrations_tests_22
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2

name: 'stripe_integration_tests'
version: '0.16.0'
version: '0.16.1'

profile: 'integration_tests'

Expand All @@ -10,7 +10,7 @@ models:
+schema: "stripe_{{ var('directed_schema','dev') }}"

vars:
stripe_schema: stripe_integrations_tests_19
stripe_schema: stripe_integrations_tests_22
stripe__standardized_billing_model_enabled: true
stripe__using_credit_notes: true
stripe_source:
Expand Down
29 changes: 14 additions & 15 deletions models/intermediate/int_stripe__date_spine.sql
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
-- depends_on: {{ ref('stripe__balance_transactions') }}
with spine as (

{% if execute %}
{% if execute and flags.WHICH in ('run', 'build') %}

{%- set first_date_query %}
select coalesce(
min(cast(balance_transaction_created_at as date)),
cast({{ dbt.dateadd("month", -1, "current_date") }} as date)
) as min_date
) as min_date
from {{ ref('stripe__balance_transactions') }}
{% endset -%}

{%- set first_date = dbt_utils.get_single_value(first_date_query) %}
{%- set first_date_pre = dbt_utils.get_single_value(first_date_query) %}
{% set first_date = "cast('" ~ first_date_pre ~ "' as date)" %}

{% set last_date_query %}
select coalesce(
greatest(max(cast(balance_transaction_created_at as date)), cast(current_date as date)),
cast(current_date as date)
) as max_date
) as max_date
from {{ ref('stripe__balance_transactions') }}
{% endset %}

{% set last_date = dbt_utils.get_single_value(last_date_query) %}
{% set last_date_pre = dbt_utils.get_single_value(last_date_query) %}
{% set last_date = "cast('" ~ last_date_pre ~ "' as date)" %}

{% else %}

{% set first_date = 'dbt.dateadd("month", -1, "current_date")' %}
{% set last_date = 'dbt.current_timestamp_backcompat()' %}
{% set first_date = dbt.dateadd("month", -1, "current_date") %}
{% set last_date = dbt.current_timestamp() %}

{% endif %}

{{ dbt_utils.date_spine(
datepart="day",
start_date="cast('" ~ first_date ~ "' as date)",
end_date=dbt.dateadd("day", 1, "cast('" ~ last_date ~ "' as date)")
)
}}
start_date=first_date,
end_date=dbt.dateadd("day", 1, last_date)
) }}

),

account as (

select *
from {{ var('account') }}
),

date_spine as (

select
cast({{ dbt.date_trunc("day", "date_day") }} as date) as date_day,
cast({{ dbt.date_trunc("week", "date_day") }} as date) as date_week,
Expand All @@ -56,7 +56,6 @@ date_spine as (
),

final as (

select distinct
account.account_id,
account.source_relation,
Expand All @@ -70,4 +69,4 @@ final as (
)

select *
from final
from final

0 comments on commit d860667

Please sign in to comment.