Skip to content

Commit

Permalink
Updated model version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dat-a-man committed Nov 28, 2024
1 parent a0c8a08 commit 2eab5b7
Show file tree
Hide file tree
Showing 56 changed files with 1,339 additions and 2,869 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ for data model which can be further modified as required.

1. The schema of data modelled above using dlt-dbt-generator:

![picture1](https://storage.googleapis.com/dlt-blog-images/stripe-dlt-dbt-package.png)
![picture1](https://storage.googleapis.com/dlt-blog-images/dbdia_stripe_dimensional_model.png)

> ⚠️ **Note:**
>
Expand Down
56 changes: 28 additions & 28 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: 'stripe_analytics'

config-version: 2
version: '0.1'

profile: 'stripe_analytics'

model-paths: ["models"]
test-paths: ["tests"]
analysis-paths: ["analysis"]
macro-paths: ["macros"]

target-path: "target"
clean-targets:
- "target"
- "dbt_modules"
- "logs"

require-dbt-version: [">=1.0.0", "<2.0.0"]

models:
stripe_analytics:
materialized: table
staging:
materialized: view
+docs:
node_color: 'silver'
+docs:
name: 'stripe_analytics'

config-version: 2
version: '0.1'

profile: 'stripe_analytics'

model-paths: ["models"]
test-paths: ["tests"]
analysis-paths: ["analysis"]
macro-paths: ["macros"]

target-path: "target"
clean-targets:
- "target"
- "dbt_modules"
- "logs"

require-dbt-version: [">=1.0.0", "<2.0.0"]

models:
stripe_analytics:
materialized: table
staging:
materialized: view
+docs:
node_color: 'silver'
+docs:
node_color: 'gold'
24 changes: 12 additions & 12 deletions models/dlt_active_load_ids.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* check if the destination already has a list of processed ids
if not we will process all loads with status 0 (==success) */
{% set active_ids_exist = adapter.get_relation(
database=this.database ,
schema=this.schema,
identifier="dlt_processed_load_ids" ) %}

SELECT load_id FROM {{ source('raw_data', '_dlt_loads') }}
WHERE status = 0
/* exclude already processed load_ids */
{% if active_ids_exist and not should_full_refresh() %}
AND load_id NOT IN (SELECT load_id FROM {{ source('transformed_data', 'dlt_processed_load_ids') }})
/* check if the destination already has a list of processed ids
if not we will process all loads with status 0 (==success) */
{% set active_ids_exist = adapter.get_relation(
database=this.database ,
schema=this.schema,
identifier="dlt_processed_load_ids" ) %}

SELECT load_id FROM {{ source('raw_data', '_dlt_loads') }}
WHERE status = 0
/* exclude already processed load_ids */
{% if active_ids_exist and not should_full_refresh() %}
AND load_id NOT IN (SELECT load_id FROM {{ source('transformed_data', 'dlt_processed_load_ids') }})
{% endif %}
64 changes: 34 additions & 30 deletions models/dlt_processed_load_ids.sql
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
{{
config(
materialized='incremental'
)
}}
-- depends_on: {{ ref('dim__dlt_loads') }}
-- depends_on: {{ ref('fact_subscription') }}
-- depends_on: {{ ref('dim_coupon') }}
-- depends_on: {{ ref('dim_customer') }}
-- depends_on: {{ ref('dim_product') }}
-- depends_on: {{ ref('dim_price') }}
-- depends_on: {{ ref('fact_event') }}
-- depends_on: {{ ref('fact_invoice') }}
-- depends_on: {{ ref('fact_balance_transaction') }}
-- depends_on: {{ ref('dim_balance_transaction__fee_details') }}
-- depends_on: {{ ref('dim_event__data__object__discounts') }}
-- depends_on: {{ ref('dim_event__data__object__lines__data') }}
-- depends_on: {{ ref('dim_event__data__object__lines__data__discount_amounts') }}
-- depends_on: {{ ref('dim_event__data__object__total_discount_amounts') }}
-- depends_on: {{ ref('dim_event__data__object__available') }}
-- depends_on: {{ ref('dim_event__data__object__pending') }}
-- depends_on: {{ ref('dim_event__data__object__payment_method_types') }}
-- depends_on: {{ ref('dim_event__data__object__items__data') }}
-- depends_on: {{ ref('dim_invoice__discounts') }}
-- depends_on: {{ ref('dim_invoice__lines__data') }}
-- depends_on: {{ ref('dim_invoice__lines__data__discount_amounts') }}
-- depends_on: {{ ref('dim_invoice__total_discount_amounts') }}
-- depends_on: {{ ref('dim_subscription__discounts') }}
-- depends_on: {{ ref('dim_subscription__items__data') }}
/* we save all currently active load ids into the processed ids table */
{{
config(
materialized='incremental'
)
}}
-- depends_on: {{ ref('dim__dlt_loads') }}
-- depends_on: {{ ref('dim_subscription') }}
-- depends_on: {{ ref('dim_coupon') }}
-- depends_on: {{ ref('dim_customer') }}
-- depends_on: {{ ref('dim_product') }}
-- depends_on: {{ ref('dim_price') }}
-- depends_on: {{ ref('dim_event') }}
-- depends_on: {{ ref('dim_invoice') }}
-- depends_on: {{ ref('dim_balance_transaction') }}
-- depends_on: {{ ref('dim_balance_transaction__fee_details') }}
-- depends_on: {{ ref('dim_event__data__object__available') }}
-- depends_on: {{ ref('dim_event__data__object__pending') }}
-- depends_on: {{ ref('dim_event__data__object__discounts') }}
-- depends_on: {{ ref('dim_event__data__object__lines__data') }}
-- depends_on: {{ ref('dim_event__data__object__lines__data__discount_amounts') }}
-- depends_on: {{ ref('dim_event__data__object__lines__data__pretax_credit_amounts') }}
-- depends_on: {{ ref('dim_event__data__object__total_discount_amounts') }}
-- depends_on: {{ ref('dim_event__data__object__total_pretax_credit_amounts') }}
-- depends_on: {{ ref('dim_event__data__object__payment_method_types') }}
-- depends_on: {{ ref('dim_event__data__object__items__data') }}
-- depends_on: {{ ref('dim_invoice__discounts') }}
-- depends_on: {{ ref('dim_invoice__lines__data') }}
-- depends_on: {{ ref('dim_invoice__lines__data__discount_amounts') }}
-- depends_on: {{ ref('dim_invoice__lines__data__pretax_credit_amounts') }}
-- depends_on: {{ ref('dim_invoice__total_discount_amounts') }}
-- depends_on: {{ ref('dim_invoice__total_pretax_credit_amounts') }}
-- depends_on: {{ ref('dim_subscription__discounts') }}
-- depends_on: {{ ref('dim_subscription__items__data') }}
/* we save all currently active load ids into the processed ids table */
select load_id, {{ current_timestamp() }} as inserted_at FROM {{ ref('dlt_active_load_ids') }}
14 changes: 0 additions & 14 deletions models/marts/dim__dlt_loads.sql

This file was deleted.

19 changes: 0 additions & 19 deletions models/marts/dim_balance_transaction__fee_details.sql

This file was deleted.

18 changes: 0 additions & 18 deletions models/marts/dim_coupon.sql

This file was deleted.

22 changes: 0 additions & 22 deletions models/marts/dim_customer.sql

This file was deleted.

18 changes: 0 additions & 18 deletions models/marts/dim_event__data__object__available.sql

This file was deleted.

16 changes: 0 additions & 16 deletions models/marts/dim_event__data__object__discounts.sql

This file was deleted.

48 changes: 0 additions & 48 deletions models/marts/dim_event__data__object__items__data.sql

This file was deleted.

60 changes: 0 additions & 60 deletions models/marts/dim_event__data__object__lines__data.sql

This file was deleted.

Loading

0 comments on commit 2eab5b7

Please sign in to comment.