From 56f270f4828c49250e39703ec78c09777cf17822 Mon Sep 17 00:00:00 2001 From: Sung Won Chung Date: Fri, 15 Sep 2023 14:39:51 -0700 Subject: [PATCH 1/3] upgrade dbt --- .gitignore | 3 +++ .user.yml | 1 + profiles.yml | 2 +- requirements.txt | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .user.yml diff --git a/.gitignore b/.gitignore index 05dada13..b5dbf75c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ target/ dbt_packages/ logs/ .DS_Store + +venv/ +.env \ No newline at end of file diff --git a/.user.yml b/.user.yml new file mode 100644 index 00000000..d42a228c --- /dev/null +++ b/.user.yml @@ -0,0 +1 @@ +id: cfcf7c98-5f78-494a-81d6-4184d6502d21 diff --git a/profiles.yml b/profiles.yml index 0d3d2488..9d65d64f 100644 --- a/profiles.yml +++ b/profiles.yml @@ -10,4 +10,4 @@ demo: database: DEMO warehouse: INTEGRATION schema: "{{ env_var('SNOWFLAKE_SCHEMA') | as_text }}" - threads: 5 + threads: 24 diff --git a/requirements.txt b/requirements.txt index 4e4c0d65..fc15ed4d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -dbt-snowflake==1.1.0 +dbt-snowflake==1.6.2 From 3cf4d11956ebc0f000a62646deec88cdd321b3b4 Mon Sep 17 00:00:00 2001 From: Sung Won Chung Date: Sun, 24 Sep 2023 09:06:04 -0700 Subject: [PATCH 2/3] correct sub plans --- models/core/dim_orgs.sql | 11 ++++++----- models/syncs/sales_sync.sql | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/models/core/dim_orgs.sql b/models/core/dim_orgs.sql index a2fc2f65..5d2262d1 100644 --- a/models/core/dim_orgs.sql +++ b/models/core/dim_orgs.sql @@ -2,9 +2,10 @@ WITH orgs AS ( --prod SELECT org_id - , MIN(event_timestamp) AS created_at - FROM {{ ref('signed_in') }} - GROUP BY 1 + , org_name + , employee_range + , created_at + FROM {{ ref('org_created') }} -- --dev -- SELECT @@ -28,7 +29,7 @@ WITH orgs AS ( org_id , event_timestamp AS sub_created_at , plan as sub_plan - , price as sub_price + , coalesce(price, 0) as sub_price FROM {{ ref('subscription_created') }} ) @@ -38,7 +39,7 @@ SELECT , created_at , num_users , sub_created_at - , sub_plan + , case when num_users = 1 then 'Individual' else sub_plan end as sub_plan , sub_price FROM orgs LEFT JOIN user_count USING (org_id) diff --git a/models/syncs/sales_sync.sql b/models/syncs/sales_sync.sql index ff10d8c5..2567aacf 100644 --- a/models/syncs/sales_sync.sql +++ b/models/syncs/sales_sync.sql @@ -3,7 +3,7 @@ WITH org_events AS ( * FROM {{ ref('dim_orgs') }} LEFT JOIN {{ ref('feature_used') }} USING (org_id) - WHERE sub_plan IS NULL + WHERE sub_plan IS NULL or sub_plan = 'Individual' ) , final AS ( From 68f493aac36590844de893a62089caeb40a2b882 Mon Sep 17 00:00:00 2001 From: Sung Won Chung Date: Mon, 29 Apr 2024 11:28:41 -0700 Subject: [PATCH 3/3] working unit test example --- models/core/dim_orgs_unit_test.yml | 17 +++++++++++++++++ requirements.txt | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 models/core/dim_orgs_unit_test.yml diff --git a/models/core/dim_orgs_unit_test.yml b/models/core/dim_orgs_unit_test.yml new file mode 100644 index 00000000..2bef7920 --- /dev/null +++ b/models/core/dim_orgs_unit_test.yml @@ -0,0 +1,17 @@ +unit_tests: + - name: test_is_individual_sub_plan + description: "Check if individual case when logic categorizes sub plans correctly for num_users equal to 1" + model: dim_orgs + given: + - input: ref('org_created') + rows: + - {org_id: 100000012, org_name: Crow Bar, domain: crowbar.edu, employee_range: 0-9, created_at: 2022-04-01 04:00:03} + - input: ref('user_created') + rows: + - {user_id: 100000021, org_id: 100000012, first_name: Tamara, last_name: Herman, email: therman@crowbar.edu, is_first_user: True, created_at: 2022-04-01T04:00:03Z} + - input: ref('subscription_created') + rows: + - {org_id: 100000011, event_timestamp: 2022-05-20T17:45:32Z, activity: subscribed, plan: Team, price: 99, deployment: SaaS} + expect: + rows: + - {org_id: 100000012, created_at: 2022-04-01 04:00:03, num_users: 1, sub_created_at: null, sub_plan: Individual, sub_price: null} diff --git a/requirements.txt b/requirements.txt index fc15ed4d..a23efd69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -dbt-snowflake==1.6.2 +dbt-snowflake==1.8.0b3 +# dbt-core==1.8.0b2 \ No newline at end of file