Skip to content
Open

test #203

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion models/core/fct_monthly_financials.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Monthly subscriber and revenue rollup
WITH final AS (
-- SELECT
-- date_trunc('month', sub_created_at) as date_month
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion models/core/fct_yearly_financials.sql
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,27 +15,31 @@
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' %}
select
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 %}
select
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 %}
Expand Down
Loading