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

Keith sandbox #126

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Empty file added analysis/test_file.sql
Empty file.
20 changes: 14 additions & 6 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ vars:
incremental_lookback_period: 'hour'
future_proof_date: '9999-12-31'

on-run-end:
- "{% if target.name == 'prod' %}{{ dbt_artifacts.upload_results(results) }}{% endif %}"
# on-run-end:
# - "{% if target.name == 'prod' %}{{ dbt_artifacts.upload_results(results) }}{% endif %}"


# Configuring models
Expand All @@ -42,12 +42,23 @@ models:
marts:
+materialized: table
+tags: ['tag']
dims:
+tags: ["myorders"]
facts:
+tags: ["myorders"]
finance:
+group: finance
marketing:
+group: marketing
operations:
+group: operations
accounting:
+group: accounting
+access: public
cfo:
+group: cfo
+access: public

intermediate:
+materialized: view
staging:
Expand All @@ -65,7 +76,4 @@ models:
+materialized: ephemeral

tests:
rapid_onboarding_exemplar:
_samples:
staging:
+store_failures: "{{ true if target.name == 'prod' else false }}"
+store_failures: false
5 changes: 5 additions & 0 deletions macros/test_macro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% macro test_macro() %}

{{ log("This is a message by log macro", info=True) }}

{% endmacro %}
11 changes: 11 additions & 0 deletions models/_groups.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
groups:
- name: cfo
owner:
# 'name' or 'email' is required; additional properties allowed
email: [email protected]

- name: accounting
owner:
email: [email protected]


1 change: 1 addition & 0 deletions models/_samples/incremental/example_incremental_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

with source as (
select * from {{ ref('example_source_for_incremental') }}

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
where _etl_loaded_at > (select max(_etl_loaded_at) from {{ this }})
Expand Down
72 changes: 0 additions & 72 deletions models/_samples/staging/jaffle_shop/_jaffle_shop__models.yml

This file was deleted.

53 changes: 0 additions & 53 deletions models/_samples/staging/jaffle_shop/stg_jaffle_shop__customers.sql

This file was deleted.

48 changes: 0 additions & 48 deletions models/_samples/staging/jaffle_shop/stg_jaffle_shop__orders.sql

This file was deleted.

36 changes: 36 additions & 0 deletions models/intermediate/finance/int_daily_orders_fact.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
with

dates as (

select * from {{ ref('dim_dates') }}

),

orders as (

select * from {{ ref('dim_orders') }}

),

countries as (

select * from {{ ref('dim_countries') }}

),

join_sources as (

select
ordr.order_sk,
country.country_sk as order_country_origin_sk,
date.date_sk as order_date_sk,
ordr.order_quantity
from orders ordr
left join dates date
on ordr.order_date = date.calendar_date
left join countries country
on ordr.order_country_origin = country.country_name

)

select * from join_sources
67 changes: 67 additions & 0 deletions models/intermediate/orders/int_revenue_fct.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{ config(
materialized='table',
tags=["cfo"]
) }}

with

depreciations as (

select * from {{ ref('dim_depreciation_accounts') }}
where account_type = 'Major'

),

interests as (

select * from {{ ref('dim_interests_accounts') }}
where account_type = 'Major'

),

net_income as (

select * from {{ ref('dim_net_income') }}
where account_type = 'Major'

),


taxes as (

select * from {{ ref('dim_tax_accounts') }}
where account_type = 'Major'

),

join_sources as (

select
net_inc.account_id,
net_inc.net_income_usd,
deprec.depreciation_cost_usd,
ints.interests_amount_usd,
tax.tax_usd,
net_inc.account_type
from net_income net_inc
left join depreciations deprec
on net_inc.account_id = deprec.account_id
left join interests ints
on net_inc.account_id = ints.account_id
left join taxes tax
on net_inc.account_id = tax.account_id

),

final as (

select
account_id,
account_type,
(net_income_usd + interests_amount_usd + tax_usd + depreciation_cost_usd)::numeric(10, 3) as ebitda
from join_sources

)

select * from final

14 changes: 14 additions & 0 deletions models/marts/cfo/fct_revenue.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ config(
materialized='table',
tags=["cfo"]
) }}

with

sources as (

select * from {{ ref('int_revenue_fct') }}

)

select * from sources
Loading
Loading