Repository navigation
Release branch/v1.10.0 - #158
Conversation
…source_relation in the daily surrogate key
…otals-by-account Partition rolling totals in stripe__daily_overview by account_id
| then 0 | ||
| else 1 | ||
| end) over (order by date_day rows unbounded preceding) as {{ f }}_partition | ||
| end) over (partition by account_id, source_relation order by date_day rows unbounded preceding) as {{ f }}_partition |
There was a problem hiding this comment.
For Redshift's sake we should use our source_relation handling macro here and in there other partion bys
| end) over (partition by account_id, source_relation order by date_day rows unbounded preceding) as {{ f }}_partition | |
| end) over (partition by account_id {{ fivetran_utils.partition_by_source_relation(package_name='stripe') }} order by date_day rows unbounded preceding) as {{ f }}_partition |
|
|
||
| {% for t in total_fields %} | ||
| , sum({{ t }}) over (order by date_day rows unbounded preceding) as rolling_{{ t }} | ||
| , sum({{ t }}) over (partition by account_id, source_relation order by date_day rows unbounded preceding) as rolling_{{ t }} |
| {% for f in rolling_fields %} | ||
| coalesce({{ f }}, | ||
| first_value({{ f }}) over (partition by {{ f }}_partition order by date_day rows unbounded preceding)) as {{ f }} | ||
| first_value({{ f }}) over (partition by account_id, source_relation, {{ f }}_partition order by date_day rows unbounded preceding)) as {{ f }} |
| partition by source_relation, subscription_item_id, invoiced_group | ||
| ) as carried_quantity | ||
| ) as carried_quantity, | ||
| max(invoiced_unit_amount) over ( | ||
| partition by source_relation, subscription_item_id, invoiced_group |
There was a problem hiding this comment.
Looks like there's some previous code we can correct too. 😄
| case | ||
| when lower(normalized.recurring_interval) = 'week' then | ||
| {{ dbt_utils.safe_divide( | ||
| effective_amount ~ " * " ~ dbt_utils.safe_divide('52', '12'), |
There was a problem hiding this comment.
I say we can remove safe divide here since 12 will never be 0, but I'll leave that up to you.
| effective_amount ~ " * " ~ dbt_utils.safe_divide('52', '12'), | |
| effective_amount ~ " * 52 / 12" , |
There was a problem hiding this comment.
Yeah, probably being overly cautious there.
fivetran-avinash
left a comment
There was a problem hiding this comment.
@fivetran-savage Approved with some changelog suggestions!
|
|
||
| | Data Model(s) | Change type | Old | New | Notes | | ||
| | ------------- | ----------- | --- | --- | ----- | | ||
| | `stripe__daily_overview` (breaking change) | Changed field | surrogate key hashed on `account_id` and `date_day`. | surrogate key hashed on `source_relation`, `account_id`, and `date_day`. | Two unioned connectors that share an account ID and a date previously produced the same key. | |
There was a problem hiding this comment.
I'd move the (breaking change) for each of the models into either the Change type or the Notes section. Data Model should just have the data models.
There was a problem hiding this comment.
Also might bold it, particularly the breaking change for all customers here.
| | `stripe__daily_overview` (breaking change) | Changed field | surrogate key hashed on `account_id` and `date_day`. | surrogate key hashed on `source_relation`, `account_id`, and `date_day`. | Two unioned connectors that share an account ID and a date previously produced the same key. | | |
| | `stripe__daily_overview` | Changed field (**breaking change**) | Surrogate key hashed on `account_id` and `date_day`. | Surrogate key hashed on `source_relation`, `account_id`, and `date_day`. | Two unioned connectors that share an account ID and a date previously produced the same key. | |
| | ------------- | ----------- | --- | --- | ----- | | ||
| | `stripe__daily_overview` (breaking change) | Changed field | surrogate key hashed on `account_id` and `date_day`. | surrogate key hashed on `source_relation`, `account_id`, and `date_day`. | Two unioned connectors that share an account ID and a date previously produced the same key. | | ||
| | `stripe__daily_overview` (possible breaking change) | Possible changed data | Each `rolling_*` column accumulated across all accounts. | Each `rolling_*` column is the running total of its own `account_id` and `source_relation`. | Only affects destinations with more than one account or more than one unioned connector. Single-account output is unchanged. See [#155](https://github.com/fivetran/dbt_stripe/issues/155). | | ||
| | `int_stripe__account_daily`, `stripe__daily_overview` (possible breaking change) | Changed join | Balance transactions and failed charges join to the date spine on the date and `source_relation` only, so every account counts every other account's activity as its own. | Both joins also match on the account. | Only affects destinations with more than one account. Transactions with no `connected_account_id` still count toward every account; see the [DECISIONLOG](https://github.com/fivetran/dbt_stripe/blob/main/DECISIONLOG.md#daily-overview-attribution-for-transactions-without-a-connected-account) for why. Single-account output is unchanged. | |
There was a problem hiding this comment.
I'd place the end model over the intermediate model.
| | `int_stripe__account_daily`, `stripe__daily_overview` (possible breaking change) | Changed join | Balance transactions and failed charges join to the date spine on the date and `source_relation` only, so every account counts every other account's activity as its own. | Both joins also match on the account. | Only affects destinations with more than one account. Transactions with no `connected_account_id` still count toward every account; see the [DECISIONLOG](https://github.com/fivetran/dbt_stripe/blob/main/DECISIONLOG.md#daily-overview-attribution-for-transactions-without-a-connected-account) for why. Single-account output is unchanged. | | |
| | `stripe__daily_overview`<br>`int_stripe__account_daily`| Changed join (**possible breaking change**) | Balance transactions and failed charges join to the date spine on the date and `source_relation` only, so every account counts every other account's activity as its own. | Both joins also match on the account. | Only affects destinations with more than one account. Transactions with no `connected_account_id` still count toward every account; see the [DECISIONLOG](https://github.com/fivetran/dbt_stripe/blob/main/DECISIONLOG.md#daily-overview-attribution-for-transactions-without-a-connected-account) for why. Single-account output is unchanged. | |
| | Data Model(s) | Change type | Old | New | Notes | | ||
| | ------------- | ----------- | --- | --- | ----- | | ||
| | `stripe__daily_overview` (breaking change) | Changed field | surrogate key hashed on `account_id` and `date_day`. | surrogate key hashed on `source_relation`, `account_id`, and `date_day`. | Two unioned connectors that share an account ID and a date previously produced the same key. | | ||
| | `stripe__daily_overview` (possible breaking change) | Possible changed data | Each `rolling_*` column accumulated across all accounts. | Each `rolling_*` column is the running total of its own `account_id` and `source_relation`. | Only affects destinations with more than one account or more than one unioned connector. Single-account output is unchanged. See [#155](https://github.com/fivetran/dbt_stripe/issues/155). | |
There was a problem hiding this comment.
Similar comment about moving (possible breaking change)
| | `stripe__daily_overview` (breaking change) | Changed field | surrogate key hashed on `account_id` and `date_day`. | surrogate key hashed on `source_relation`, `account_id`, and `date_day`. | Two unioned connectors that share an account ID and a date previously produced the same key. | | ||
| | `stripe__daily_overview` (possible breaking change) | Possible changed data | Each `rolling_*` column accumulated across all accounts. | Each `rolling_*` column is the running total of its own `account_id` and `source_relation`. | Only affects destinations with more than one account or more than one unioned connector. Single-account output is unchanged. See [#155](https://github.com/fivetran/dbt_stripe/issues/155). | | ||
| | `int_stripe__account_daily`, `stripe__daily_overview` (possible breaking change) | Changed join | Balance transactions and failed charges join to the date spine on the date and `source_relation` only, so every account counts every other account's activity as its own. | Both joins also match on the account. | Only affects destinations with more than one account. Transactions with no `connected_account_id` still count toward every account; see the [DECISIONLOG](https://github.com/fivetran/dbt_stripe/blob/main/DECISIONLOG.md#daily-overview-attribution-for-transactions-without-a-connected-account) for why. Single-account output is unchanged. | | ||
| | `stripe__subscription_item_mrr_report` (possible breaking change) | Changed model | Historical months apply the item's current `price_plan` unit amount. | Historical months apply the `unit_amount_excluding_tax` from the invoice line that billed them, carried forward across gap months. | MRR now reflects a price change from the month it took effect instead of applying today's price across all history, so historical `month_contract_mrr`, `month_discount_applied`, `month_billed_mrr`, and `contract_mrr_type` values change. Months with no invoiced unit amount still use the live `price_plan` unit amount. See the [DECISIONLOG](https://github.com/fivetran/dbt_stripe/blob/main/DECISIONLOG.md#mrr-history-anchored-to-each-subscription-items-creation-date). | |
There was a problem hiding this comment.
Similar comment about moving (possible breaking change)
PR Overview
Package version introduced in this PR:
This PR addresses the following Issue/Feature(s):
Summary of changes:
source_relationto the surrogate key forstripe__daily_overviewaccount_idandsource_relationto rolling fields partition instripe__daily_overview,int_stripe__account_partitions, andint_stripe__account_rolling_totals.account_idto date spine join inint_stripe__dailyandstripe__daily_overview.unit_amount_excluding_taxfield tostg_stripe__invoice_line_item.stripe__subscription_item_mrr_reportfromstg_stripe__invoice_line_item.Submission Checklist
Changelog