File tree Expand file tree Collapse file tree 8 files changed +64
-24
lines changed
macros/dune_dbt_overrides Expand file tree Collapse file tree 8 files changed +64
-24
lines changed Original file line number Diff line number Diff line change @@ -26,23 +26,27 @@ jobs:
2626 - name : Install dependencies with uv
2727 run : uv sync
2828
29+ - name : Setup variables
30+ run : |
31+ echo "PROFILE=--profiles-dir $HOME/.dbt --profile dunesql" >> $GITHUB_ENV
32+
2933 - name : Run dbt deps
3034 run : uv run dbt deps
3135
3236 - name : Activate Trino cluster
3337 run : " ./scripts/activate-trino-cluster.sh"
3438
3539 - name : Run dbt compile
36- run : uv run dbt compile
40+ run : uv run dbt compile $PROFILE
3741
3842 - name : Run dbt run (full refresh)
39- run : uv run dbt run --full-refresh
43+ run : uv run dbt run $PROFILE --full-refresh
4044
4145 - name : Run dbt test (after full refresh)
42- run : uv run dbt test
46+ run : uv run dbt test $PROFILE
4347
4448 - name : Run dbt run (incremental update)
45- run : uv run dbt run
49+ run : uv run dbt run $PROFILE
4650
4751 - name : Run dbt test (after incremental)
48- run : uv run dbt test
52+ run : uv run dbt test $PROFILE
Original file line number Diff line number Diff line change 11{#
2- goal: depending on how we handle dev vs. prod environments (i .e . s3 bucket names ), we may not need this macro override
2+ goal: depending on how we handle dev vs. prod environments (i .e . s3), we may not need this macro override
33
44 Custom schema naming logic for dev vs prod environments
55
1919{% macro generate_schema_name(custom_schema_name, node) -%}
2020
2121 {%- set default_schema = target.schema -%}
22- {%- if custom_schema_name is none -%}
23-
24- {{ default_schema }}
22+ {%- if target.name == ' prod ' and custom_schema_name is not none -%}
23+ {# prod environment #}
24+ {{ custom_schema_name | trim }}
2525
26- {%- elif target.name == ' prod' -%}
26+ {%- elif target.schema.startswith("github_actions") -%}
27+ {# test environment, CI pipeline #}
28+ {{ ' test_schema' }}
2729
28- {{ custom_schema_name | trim }}
30+ {%- elif custom_schema_name is none -%}
31+
32+ {{ default_schema }}
2933
3034 {%- else -%}
31-
35+ {# dev environment, running locally #}
3236 {{ default_schema }}_{{ custom_schema_name | trim }}
3337
3438 {%- endif -%}
3539
36- {%- endmacro %}
37-
40+ {%- endmacro %}
Original file line number Diff line number Diff line change 66 columns :
77 - name : block_number
88 description : " The unique block number in last 1 day"
9+ - name : block_date
10+ description : " The date of the block"
11+ - name : total_tx_per_block
12+ description : " The total number of transactions per block"
13+ - name : dbt_template_table_model
14+ description : " A starter dbt table model"
15+ columns :
16+ - name : block_number
17+ description : " The unique block number in last 1 day"
18+ - name : block_date
19+ description : " The date of the block"
20+ - name : total_tx_per_block
21+ description : " The total number of transactions per block"
22+ - name : dbt_template_incremental_model
23+ description : " A starter dbt incremental model"
24+ data_tests :
25+ - dbt_utils.unique_combination_of_columns :
26+ combination_of_columns :
27+ - block_number
28+ - block_date
29+ columns :
30+ - name : block_number
31+ description : " The unique block number in last 1 day"
32+ - name : block_date
33+ description : " The date of the block"
934 - name : total_tx_per_block
1035 description : " The total number of transactions per block"
Original file line number Diff line number Diff line change 55# }
66
77{{ config(
8- schema = ' dbt_template '
9- , alias = ' incremental_model '
8+ schema = ' test_schema '
9+ , alias = ' dbt_template_incremental_model '
1010 , materialized = ' incremental'
1111 , incremental_strategy = ' merge'
1212 , unique_key = [' block_number' , ' block_date' ]
1818select
1919 block_number
2020 , block_date
21- , count (1 ) as total_tx_per_block
21+ , count (1 ) as total_tx_per_block -- count per block
2222from
2323 {{ source(' ethereum' , ' transactions' ) }}
2424where
Original file line number Diff line number Diff line change 77#}
88
99{{ config(
10- schema = ' dbt_template '
11- , alias = ' table_model '
10+ schema = ' test_schema '
11+ , alias = ' dbt_template_table_model '
1212 , materialized = ' table'
1313 , on_table_exists = ' replace'
1414)
1515}}
1616
1717select
1818 block_number
19+ , block_date
1920 , count(1) as total_tx_per_block
2021from
2122 {{ source(' ethereum' , ' transactions' ) }}
2223where
2324 block_date >= now() - interval ' 1 ' day
2425group by
25- block_number
26+ block_number
27+ , block_date
Original file line number Diff line number Diff line change 11{{ config(
2- schema = ' dbt_template '
3- , alias = ' view_model '
2+ schema = ' test_schema '
3+ , alias = ' dbt_template_view_model '
44 , materialized = ' view'
55)
66}}
77
88select
99 block_number
10+ , block_date
1011 , count (1 ) as total_tx_per_block
1112from
1213 {{ source(' ethereum' , ' transactions' ) }}
1314where
1415 block_date >= now() - interval ' 1' day
1516group by
16- block_number
17+ block_number
18+ , block_date
Original file line number Diff line number Diff line change 1+ packages :
2+ - package : dbt-labs/dbt_utils
3+ version : [">=1.0.0", "<2.0.0"]
4+
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ WAIT_TIME=15
99
1010until [ " $RETRY_COUNT " -ge " $MAX_RETRIES " ]
1111do
12- uv run dbt debug && break
12+ uv run dbt debug $PROFILE && break
1313 RETRY_COUNT=$(( RETRY_COUNT+ 1 ))
1414 if [ " $RETRY_COUNT " -ge " $MAX_RETRIES " ]; then
1515 echo " Max retries reached, failing..."
You can’t perform that action at this time.
0 commit comments