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

add staging models for normalized models #76

Closed
wants to merge 18 commits into from
Closed
2 changes: 2 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vars:
credit_note: "{{ source('stripe', 'credit_note') }}"
credit_note_line_item: "{{ source('stripe', 'credit_note_line_item') }}"
customer: "{{ source('stripe', 'customer') }}"
discount: "{{ source('stripe', 'discount') }}"
dispute: "{{ source('stripe', 'dispute') }}"
fee: "{{ source('stripe', 'fee') }}"
invoice: "{{ source('stripe', 'invoice') }}"
Expand All @@ -28,6 +29,7 @@ vars:
payout: "{{ source('stripe', 'payout') }}"
plan: "{{ source('stripe', 'plan') }}"
price: "{{ source('stripe', 'price') }}"
product: "{{ source('stripe', 'product') }}"
refund: "{{ source('stripe', 'refund') }}"
subscription_history: "{{ source('stripe', 'subscription_history') }}"
subscription: "{{ source('stripe', 'subscription') }}"
Expand Down
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_source_integrations_tests_4
schema: stripe_source_integrations_tests_5
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: stripe_source_integrations_tests_4
schema: stripe_source_integrations_tests_5
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_source_integrations_tests_4
schema: stripe_source_integrations_tests_5
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_source_integrations_tests_4
schema: stripe_source_integrations_tests_5
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_source_integrations_tests_4
schema: stripe_source_integrations_tests_5
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
14 changes: 13 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ version: '0.11.1'
profile: 'integration_tests'

vars:
stripe_schema: stripe_source_integrations_tests_4
stripe_schema: stripe_source_integrations_tests_5
stripe_source:
stripe_account_identifier: "account_data"
stripe_group_identifier: "group_data"
stripe_balance_transaction_identifier: "balance_transaction_data"
stripe_card_identifier: "card_data"
stripe_charge_identifier: "charge_data"
stripe_customer_identifier: "customer_data"
stripe_discount_identifier: "discount_data"
stripe_dispute_identifier: "dispute_data"
stripe_fee_identifier: "fee_data"
stripe_invoice_identifier: "invoice_data"
Expand All @@ -24,6 +25,7 @@ vars:
stripe_payment_method_identifier: "payment_method_data"
stripe_payout_identifier: "payout_data"
stripe_plan_identifier: "plan_data"
stripe_product_identifier: "product_data"
stripe_price_identifier: "price_data"
stripe_refund_identifier: "refund_data"
stripe_subscription_history_identifier: "subscription_history_data"
Expand All @@ -39,6 +41,7 @@ seeds:
_fivetran_synced: timestamp
created: timestamp
voided_at: timestamp
end: timestamp
account_data:
+column_types:
id: "{%- if target.type == 'bigquery' -%} INT64 {%- else -%} bigint {%- endif -%}"
Expand All @@ -47,6 +50,15 @@ seeds:
invoice_data:
+column_types:
id: "{{ 'varchar(100)' if target.name in ('redshift', 'postgres') else 'string' }}"
discount_data:
+enabled: "{{ true if target.type not in ('snowflake', 'postgres') else false }}"
discount_data_snowflake:
+alias: discount_data
+enabled: "{{ true if target.type == 'snowflake' else false }}"
discount_data_postgres:
+alias: discount_data
+enabled: "{{ true if target.type == 'postgres' else false }}"


dispatch:
- macro_namespace: dbt_utils
Expand Down
11 changes: 11 additions & 0 deletions integration_tests/seeds/discount_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id,type,type_id,_fivetran_synced,amount,checkout_session_id,checkout_session_line_item_id,coupon_id,credit_note_line_item_id,customer_id,end,invoice_id,invoice_item_id,promotion_code,start,subscription_id
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1a1b99DZlKRVG8Gn5eb6dced,2024-03-19 12:32:16.476000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OvvZQDZlKRVG8GnByl08x0P,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1cd03bDZlKRVG8Gn694a7916,2024-02-19 12:32:46.371000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OlPk3DZlKRVG8GnkWTFA0go,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_15a605DZlKRVG8Gncf06fd6b,2024-02-16 18:45:08.587000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OaAyXDZlKRVG8GnQo19CbEo,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1d3987DZlKRVG8Gnb404c3ca,2023-11-19 08:18:47.498000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1432ddDZlKRVG8Gna92778f6,2024-04-19 07:45:08.824000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1P7ALFDZlKRVG8GnTUCtI40b,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1a71eaDZlKRVG8Gn3909c3a4,2024-02-16 18:33:16.340000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OOwCbDZlKRVG8Gn3Tfhz2RW,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_146059DZlKRVG8Gn63a45e70,2024-05-19 12:34:05.168000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1PI2dvDZlKRVG8Gn4I34kEqR,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,SUBSCRIPTION,sub_1LjcrrDZlKRVG8Gnv1Bjosun,2024-05-19 06:31:36.758000,,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1NcPsdDZlKRVG8GnU0gsnD2b,CUSTOMER,cus_OPEJRxhitWa90P,2023-10-17 14:18:42.776000,,,,ioLCPhMr,,cus_OPEJRxhitWa90P,,,,,2023-08-07 09:37:39.000000,
di_1NcPt3DZlKRVG8GnqM2ZJTve,CUSTOMER,cus_OPEKG00sHdsUs8,2024-06-06 12:32:41.114000,,,,Oodskd5H,,cus_OPEKG00sHdsUs8,,,,,2023-08-07 09:38:05.000000,
11 changes: 11 additions & 0 deletions integration_tests/seeds/discount_data_postgres.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id,type,type_id,_fivetran_synced,amount,checkout_session_id,checkout_session_line_item_id,coupon_id,credit_note_line_item_id,customer_id,"""end""",invoice_id,invoice_item_id,promotion_code,"""start""",subscription_id
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1a1b99DZlKRVG8Gn5eb6dced,2024-03-19 12:32:16.476000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-27 05:50:07.000000",in_1OvvZQDZlKRVG8GnByl08x0P,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1cd03bDZlKRVG8Gn694a7916,2024-02-19 12:32:46.371000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-22 05:50:07.000000",in_1OlPk3DZlKRVG8GnkWTFA0go,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_15a605DZlKRVG8Gncf06fd6b,2024-02-16 18:45:08.587000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-27 05:50:07.000000",in_1OaAyXDZlKRVG8GnQo19CbEo,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1d3987DZlKRVG8Gnb404c3ca,2023-11-19 08:18:47.498000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-22 05:50:07.000000",,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1432ddDZlKRVG8Gna92778f6,2024-04-19 07:45:08.824000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-27 05:50:07.000000",in_1P7ALFDZlKRVG8GnTUCtI40b,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1a71eaDZlKRVG8Gn3909c3a4,2024-02-16 18:33:16.340000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-22 05:50:07.000000",in_1OOwCbDZlKRVG8Gn3Tfhz2RW,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_146059DZlKRVG8Gn63a45e70,2024-05-19 12:34:05.168000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-27 05:50:07.000000",in_1PI2dvDZlKRVG8Gn4I34kEqR,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,SUBSCRIPTION,sub_1LjcrrDZlKRVG8Gnv1Bjosun,2024-05-19 06:31:36.758000,,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,"2022-09-22 05:50:07.000000",,,,"2022-09-19 05:50:07.000000",sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1NcPsdDZlKRVG8GnU0gsnD2b,CUSTOMER,cus_OPEJRxhitWa90P,2023-10-17 14:18:42.776000,,,,ioLCPhMr,,cus_OPEJRxhitWa90P,"2022-09-27 05:50:07.000000",,,,"2023-08-07 09:37:39.000000",
di_1NcPt3DZlKRVG8GnqM2ZJTve,CUSTOMER,cus_OPEKG00sHdsUs8,2024-06-06 12:32:41.114000,,,,Oodskd5H,,cus_OPEKG00sHdsUs8,,,,,"2023-08-07 09:38:05.000000",
11 changes: 11 additions & 0 deletions integration_tests/seeds/discount_data_snowflake.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id,type,type_id,_fivetran_synced,amount,checkout_session_id,checkout_session_line_item_id,coupon_id,credit_note_line_item_id,customer_id,"""END""",invoice_id,invoice_item_id,promotion_code,"""START""",subscription_id
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1a1b99DZlKRVG8Gn5eb6dced,2024-03-19 12:32:16.476000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OvvZQDZlKRVG8GnByl08x0P,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1cd03bDZlKRVG8Gn694a7916,2024-02-19 12:32:46.371000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OlPk3DZlKRVG8GnkWTFA0go,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_15a605DZlKRVG8Gncf06fd6b,2024-02-16 18:45:08.587000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OaAyXDZlKRVG8GnQo19CbEo,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1d3987DZlKRVG8Gnb404c3ca,2023-11-19 08:18:47.498000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1432ddDZlKRVG8Gna92778f6,2024-04-19 07:45:08.824000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1P7ALFDZlKRVG8GnTUCtI40b,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_1a71eaDZlKRVG8Gn3909c3a4,2024-02-16 18:33:16.340000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1OOwCbDZlKRVG8Gn3Tfhz2RW,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,PARENT_INVOICE_LINE_ITEM,sli_146059DZlKRVG8Gn63a45e70,2024-05-19 12:34:05.168000,101,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,in_1PI2dvDZlKRVG8Gn4I34kEqR,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1LjcrrDZlKRVG8GnP7REhm8t,SUBSCRIPTION,sub_1LjcrrDZlKRVG8Gnv1Bjosun,2024-05-19 06:31:36.758000,,,,ojshw0ZH,,cus_MSXtGSAxxtYWe1,,,,,2022-09-19 05:50:07.000000,sub_1LjcrrDZlKRVG8Gnv1Bjosun
di_1NcPsdDZlKRVG8GnU0gsnD2b,CUSTOMER,cus_OPEJRxhitWa90P,2023-10-17 14:18:42.776000,,,,ioLCPhMr,,cus_OPEJRxhitWa90P,,,,,2023-08-07 09:37:39.000000,
di_1NcPt3DZlKRVG8GnqM2ZJTve,CUSTOMER,cus_OPEKG00sHdsUs8,2024-06-06 12:32:41.114000,,,,Oodskd5H,,cus_OPEKG00sHdsUs8,,,,,2023-08-07 09:38:05.000000,
11 changes: 11 additions & 0 deletions integration_tests/seeds/product_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id,_fivetran_synced,active,caption,created,description,is_deleted,livemode,metadata,name,package_dimensions_height,package_dimensions_length,package_dimensions_weight,package_dimensions_width,shippable,statement_descriptor,type,unit_label,updated,url
prod_MSXxXVG5G0v6gH,2024-05-19 12:34:06.327000,true,,2022-09-19 05:49:41.000000,,false,true,{},Premium Membership,,,,,,,service,,2022-09-19 05:49:41.000000,
prod_PT6r0SAJoY9uCp,2024-01-30 12:31:51.809000,true,Mac book,2024-01-30 06:18:03.000000,M1 chip,false,true,{},Laptop,,,,,true,,good,,2024-01-30 06:22:27.000000,example.com
prod_FS1XReP8QHQIoO,2024-02-27 12:32:13.504000,true,,2019-07-17 07:24:19.000000,,false,true,{},Test_product 1,,,,,,,service,,2022-05-05 19:13:59.000000,
prod_O2mRKRlBamTgbK,2023-11-08 14:18:15.371000,true,,2023-06-08 11:20:00.000000,,false,true,{},zzzz,,,,,,,service,,2023-06-08 11:20:00.000000,
prod_NerEckYh6qjN5j,2024-06-05 12:31:29.500000,true,,2023-04-05 14:40:46.000000,,false,true,{},Test product for quanity,,,,,,,service,,2023-04-05 14:40:46.000000,
prod_FS5To91GXlYRTf,2022-11-16 20:28:40.972000,true,,2019-07-17 11:27:24.000000,,false,true,{},test_prod3,,,,,,,service,,2022-05-05 19:13:59.000000,
prod_PT7q4GGj2pp4G4,2024-01-30 12:31:51.817000,true,,2024-01-30 07:18:38.000000,Black,false,true,{},Mobile phone,,,,,,,service,,2024-01-30 07:51:03.000000,
prod_M2koytwH0sHCcy,2022-11-16 20:23:09.806000,true,,2022-07-12 09:22:46.000000,,false,true,{},test_product,,,,,,,service,,2022-07-12 09:22:46.000000,
prod_P2hUxfvJwQcDMe,2023-12-05 08:18:45.455000,true,,2023-11-20 18:20:24.000000,,false,true,{},take 1,,,,,,,service,,2023-11-20 18:20:24.000000,
prod_NhMlgl7UvBDDt5,2023-10-19 08:18:18.743000,true,,2023-04-12 07:23:48.000000,This is test product created for the tax rate testing,false,true,{},AWS EKS Training,,,,,,,service,,2023-04-12 07:23:49.000000,
30 changes: 30 additions & 0 deletions macros/get_discount_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% macro get_discount_columns() %}

{% set columns = [
{"name": "id", "datatype": dbt.type_string() },
{"name": "type", "datatype": dbt.type_string() },
{"name": "type_id", "datatype": dbt.type_string() },
{"name": "_fivetran_synced", "datatype": dbt.type_timestamp() },
{"name": "amount", "datatype": dbt.type_int() },
{"name": "checkout_session_id", "datatype": dbt.type_string() },
{"name": "checkout_session_line_item_id", "datatype": dbt.type_string() },
{"name": "coupon_id", "datatype": dbt.type_string() },
{"name": "credit_note_line_item_id", "datatype": dbt.type_string() },
{"name": "customer_id", "datatype": dbt.type_string() },
{"name": "invoice_id", "datatype": dbt.type_string() },
{"name": "invoice_item_id", "datatype": dbt.type_string() },
{"name": "promotion_code", "datatype": dbt.type_string() },
{"name": "subscription_id", "datatype": dbt.type_string() }
] %}

{% if target.type == 'snowflake' %}
{{ columns.append({"name": "END", "datatype": dbt.type_string(), "quote": True, "alias": "end_at"}) }},
{{ columns.append({"name": "START", "datatype": dbt.type_string(), "quote": True, "alias": "start_at"}) }}
{% else %}
{{ columns.append({"name": "end", "datatype": dbt.type_string(), "quote": True, "alias": "end_at"}) }},
{{ columns.append({"name": "start", "datatype": dbt.type_string(), "quote": True, "alias": "start_at"}) }}
{% endif %}

{{ return(columns) }}

{% endmacro %}
26 changes: 26 additions & 0 deletions macros/get_product_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% macro get_product_columns() %}

{% set columns = [
{"name": "fivetran_synced", "datatype": dbt.type_timestamp()},
{"name": "id", "datatype": dbt.type_string()},
{"name": "active", "datatype": "boolean","alias": "is_active"},
{"name": "attributes", "datatype": dbt.type_string()},
{"name": "caption", "datatype": dbt.type_string()},
{"name": "created", "datatype": dbt.type_timestamp()},
{"name": "deactivate_on", "datatype": dbt.type_timestamp()},
{"name": "description", "datatype": dbt.type_string()},
{"name": "images", "datatype": dbt.type_string()},
{"name": "is_deleted", "datatype": "boolean"},
{"name": "livemode", "datatype": "boolean"},
{"name": "name", "datatype": dbt.type_string()},
{"name": "shippable", "datatype": "boolean"},
{"name": "statement_descriptor", "datatype": dbt.type_string()},
{"name": "type", "datatype": dbt.type_string()},
{"name": "unit_label", "datatype": dbt.type_string()},
{"name": "updated", "datatype": dbt.type_timestamp()},
{"name": "url", "datatype": dbt.type_string()}
] %}

{{ return(columns) }}

{% endmacro %}
15 changes: 15 additions & 0 deletions models/src_stripe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -953,3 +953,18 @@ sources:
- name: transfer_group
description: A string that identifies this transaction as part of a group. See the Connect documentation for details.


- name: product
identifier: "{{ var('stripe_product_identifier', 'product')}}"
description: to complete
freshness: null

- name: discount
identifier: "{{ var('stripe_discount_identifier', 'discount')}}"
description: to complete
freshness: null
columns:
- name: end
description: to complete
- name: start
description: to complete
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
51 changes: 51 additions & 0 deletions models/stg_stripe__discount.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

with base as (

select *
from {{ ref('stg_stripe__discount_tmp') }}
),

fields as (

select
{{
fivetran_utils.fill_staging_columns(
source_columns=adapter.get_columns_in_relation(ref('stg_stripe__discount_tmp')),
staging_columns=get_discount_columns()
)
}}

{{ fivetran_utils.source_relation(
union_schema_variable='stripe_union_schemas',
union_database_variable='stripe_union_databases')
}}

from base
),

final as (

select
id as discount_id,
type,
type_id,
_fivetran_synced,
amount,
checkout_session_id,
checkout_session_line_item_id,
coupon_id,
credit_note_line_item_id,
customer_id,
cast(end_at as {{ dbt.type_timestamp() }}) as end_at, -- renamed in macro get_discount_columns, source column name: end
invoice_id,
invoice_item_id,
promotion_code,
cast(start_at as {{ dbt.type_timestamp() }}) as start_at, -- renamed in macro get_discount_columns, source column name: start
subscription_id,
source_relation

from fields
)

select *
from final
54 changes: 54 additions & 0 deletions models/stg_stripe__product.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{ config(enabled=var('stripe__using_subscriptions', True)) }}
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved

with product as (

select *
from {{ ref('stg_stripe__product_tmp') }}
),

fields as (

select
{{
fivetran_utils.fill_staging_columns(
source_columns=adapter.get_columns_in_relation(ref('stg_stripe__product_tmp')),
staging_columns=get_product_columns()
)
}}

{{ fivetran_utils.source_relation(
union_schema_variable='stripe_union_schemas',
union_database_variable='stripe_union_databases')
}}

from product
),

final as (

select
id as product_id,
is_active, -- renamed in macro
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
attributes,
caption,
cast(created as {{ dbt.type_timestamp() }}) as created_at,
cast(deactivate_on as {{ dbt.type_timestamp() }}) as deactivate_at,
description,
images,
is_deleted,
name,
shippable,
statement_descriptor,
type,
unit_label,
updated,
url,
source_relation

from fields
{{ livemode_predicate() }}
)

select *
from final

12 changes: 12 additions & 0 deletions models/tmp/stg_stripe__discount_tmp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{
fivetran_utils.union_data(
table_identifier='discount',
database_variable='stripe_database',
schema_variable='stripe_schema',
default_database=target.database,
default_schema='stripe',
default_variable='discount',
union_schema_variable='stripe_union_schemas',
union_database_variable='stripe_union_databases'
)
}}
Loading