This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ config( | |
tags=["finance"] | |
) }} | |
{% macro centralize_test_failures(results) %} | |
{# --add "{{ centralize_test_failures(results) }}" to an on-run-end: block in dbt_project.yml #} | |
{# --run with dbt build --store-failures. #} | |
{%- set test_results = [] -%} | |
{%- for result in results -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with campaigns as ( | |
select * from {{ ref('stg_campaigns') }} | |
), | |
campaign_sequence as ( | |
select * from {{ ref('stg_campaign_sequence') }} | |
), | |
final as ( | |
select | |
campaign_sequence.campaign_id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
sources: | |
- name: csv_load | |
database: adinsmoor_sandbox_dev | |
schema: loading_layer | |
tables: | |
- name: sw_line_input | |
- name: recipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Exercise 1: Define a staging model (stg_player.sql) | |
with player as ( | |
select * from {{ source('fifa', 'player') }} | |
) | |
select | |
id as player_id | |
, affiliation_id | |
, concat(player_first_name, ' ', player_last_name) as player_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Exercise 1: Define a staging model (stg_player.sql) | |
with player as ( | |
select * from {{ source('fifa', 'player') }} | |
) | |
select | |
id as player_id | |
, affiliation_id | |
, concat(player_first_name, ' ', player_last_name) as player_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1A) dim_customers SQL | |
select | |
store_id || "-" || cast(id as string) as unique_id | |
, id | |
, store_id | |
, name | |
from {{ source('apjuice', 'users') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1A) dim_customers SQL | |
select | |
store_id || "-" || cast(id as string) as unique_id | |
, id | |
, store_id | |
, name | |
from {{ source('apjuice', 'users') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- add a dispatch command to your dbt_project.yml file (where my_project is your project name) | |
dispatch: | |
- macro_namespace: logging | |
search_order: ['my_project', ' logging'] | |
-- modify the macro with desired customizations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
--add "{{ store_test_results(results) }}" to an on-run-end: block in dbt_project.yml | |
--run with dbt build --store-failures. The next v.1.0.X release of dbt will include post run hooks for dbt test! | |
*/ | |
{% macro store_test_results(results) %} | |
{%- set test_results = [] -%} | |
{%- for result in results if result.node.resource_type == 'test' -%} | |
{%- set test_results = test_results.append(result) -%} |