diff --git a/models/core/fct_monthly_financials.sql b/models/core/fct_monthly_financials.sql index 409dab6e..b86eab92 100644 --- a/models/core/fct_monthly_financials.sql +++ b/models/core/fct_monthly_financials.sql @@ -1,3 +1,4 @@ +-- Monthly subscriber and revenue rollup WITH final AS ( -- SELECT -- date_trunc('month', sub_created_at) as date_month @@ -13,6 +14,7 @@ WITH final AS ( date_trunc('month', sub_created_at) as date_month , count(distinct org_id) as cnt_subscribers , sum(sub_price) as sum_revenue + , 'test' as test_column FROM {{ ref('dim_orgs') }} WHERE sub_created_at is not NULL GROUP BY 1 @@ -22,6 +24,7 @@ WITH final AS ( date_trunc('month', sub_created_at) as date_month , count(distinct org_id) as cnt_subscribers , sum(sub_price) as sum_revenue + , 'test' as test_column FROM {{ ref('dim_orgs') }} WHERE sub_created_at is not NULL GROUP BY 1 @@ -30,7 +33,8 @@ WITH final AS ( SELECT TIMESTAMP_TRUNC(sub_created_at, month) AS date_month, COUNT(DISTINCT org_id) AS cnt_subscribers, - SUM(sub_price) AS sum_revenue + SUM(sub_price) AS sum_revenue, + 'test' AS test_column FROM {{ ref('dim_orgs') }} WHERE NOT sub_created_at IS NULL GROUP BY 1 @@ -40,6 +44,7 @@ WITH final AS ( date_trunc('month', sub_created_at) as date_month , count(distinct org_id) as cnt_subscribers , sum(sub_price) as sum_revenue + , 'test' as test_column FROM {{ ref('dim_orgs') }} WHERE sub_created_at is not NULL GROUP BY 1 diff --git a/models/core/fct_yearly_financials.sql b/models/core/fct_yearly_financials.sql index f103b9fd..b7a3b0ba 100644 --- a/models/core/fct_yearly_financials.sql +++ b/models/core/fct_yearly_financials.sql @@ -1,3 +1,4 @@ +-- Yearly rollup built on top of fct_monthly_financials -- select -- date_trunc('year', date_month) as date_year -- , sum(cnt_subscribers) as yearly_subscribers @@ -14,6 +15,7 @@ date_trunc('year', date_month) as date_year , sum(cnt_subscribers) as yearly_subscribers , sum(sum_revenue) as yearly_revenue + , 'test' as test_column from {{ref('fct_monthly_financials')}} group by 1 {% elif target.name == 'db' %} @@ -21,13 +23,15 @@ date_trunc('year', date_month) as date_year , sum(cnt_subscribers) as yearly_subscribers , sum(sum_revenue) as yearly_revenue + , 'test' as test_column from {{ref('fct_monthly_financials')}} group by 1 {% elif target.name == 'bq' %} SELECT DATE_TRUNC(date_month, YEAR) AS date_year, SUM(cnt_subscribers) AS yearly_subscribers, - SUM(sum_revenue) AS yearly_revenue + SUM(sum_revenue) AS yearly_revenue, + 'test' AS test_column FROM {{ ref('fct_monthly_financials') }} GROUP BY 1 {% else %} @@ -35,6 +39,7 @@ date_trunc('year', date_month) as date_year , sum(cnt_subscribers) as yearly_subscribers , sum(sum_revenue) as yearly_revenue + , 'test' as test_column from {{ref('fct_monthly_financials')}} group by 1 {% endif %}