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 current_data as ( | |
select * from {{ source_table }} | |
), | |
archived_data as ( | |
select * from {{ this }} |
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
-- Macros to add indexes: | |
-- macros/indexes.sql | |
{% macro index(this, column) %} | |
drop index if exists "{{ this.schema }}"."{{ this.name }}__index_on_{{ column }}" cascade; | |
create index "{{ this.name }}__index_on_{{ column }}" on {{ this }} ("{{ column }}") | |
{% endmacro %} |
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
#!/bin/bash | |
INSANE_PYTHON='/usr/bin/python' # not sane? | |
VENV_PATH="$HOME/.dbt/dbt-dev-env" | |
DBT_REPO_REMOTE="https://github.com/fishtown-analytics/dbt.git" | |
DBT_LOCAL_PATH="${TMPDIR}dbt-development" | |
DBT_ALIAS="use-dbt-dev" | |
function install_python() { | |
echo 'Installing python' |
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
import sys | |
import networkx as nx | |
if len(sys.argv) != 2: | |
print("Usage: {} [path/to/graph.gpickle]".format(sys.argv[0])) | |
sys.exit(1) | |
filename = sys.argv[1] | |
graph = nx.read_gpickle(sys.argv[1]) |
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
-- pseudocode: | |
``` | |
{% set table_comment = "here is a comment about my table" %} | |
{% set column_comments = { | |
"column_1": "column 1 comment is...", | |
"column_2": "column 2 comment is...", | |
} | |
%} |
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
{%- call statement('states', fetch_result=True) -%} | |
select distinct state from {{ ref('users') }} | |
{%- endcall -%} |
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
-- Load the results of our statement and select the first column | |
{%- set states = load_result('states')['data'] | map(attribute=0)-%} | |
select | |
*, | |
-- Loop over each state | |
{% for state in states | list -%} | |
case |
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
select | |
id, | |
user_id, | |
price, | |
null::timestamp as returned_at -- this column doesn't exist! | |
from ecom_us.orders | |
union all | |
select |
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
select | |
'analytics.uk_orders'::text as _dbt_source_table, | |
"id"::integer as "id", | |
"user_id"::character varying(255) as "user_id", | |
"price"::character varying(255) as "price", | |
"returned_at"::timestamp without time zone as "returned_at" | |
from analytics.uk_orders |
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
{% set orders_tables = [ | |
ref('orders_uk'), | |
ref('orders_us')] | |
%} | |
{{ union_tables(orders_tables) }} |
OlderNewer