Skip to content

Commit 0d9922c

Browse files
authoredJun 1, 2022
T 12902 optimize macro instead of on run end (#1106)
Instead of having multiple OPTIMIZE commands running on-run-end, I just implemented a macro that I attach to the weekly job, as well as the newly created "Manually Deploy New Version" job :) <img width="1350" alt="Capture d’écran 2022-06-01 à 13 13 59" src="https://user-images.githubusercontent.com/66172107/171393092-0559e939-cf65-46c5-99dd-06cf16d64e09.png"> I've checked that: * [ ] I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory) * [ ] I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables * [ ] the directory tree matches the pattern /sector/blockchain/ e.g. /tokens/ethereum * [ ] if adding a new model, I added a test * [ ] the filename is unique and ends with .sql * [ ] each file has only one view, table or function defined * [ ] column names are `lowercase_snake_cased`
1 parent d87c372 commit 0d9922c

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed
 

‎spellbook/dbt_project.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,4 @@ seeds:
113113
tx_hash: string
114114
amount: string
115115

116-
on-run-end:
117-
- "OPTIMIZE transfers_ethereum.erc20_agg_hour"
118-
- "OPTIMIZE transfers_ethereum.erc20_agg_day"
119-
- "OPTIMIZE opensea_ethereum.trades"
120-
- "OPTIMIZE opensea_solana.trades"
121-
- "OPTIMIZE magiceden_solana.trades"
116+

‎spellbook/macros/optimize_tables.sql

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{% macro optimize_tables() %}
2+
{%- if flags.full_refresh -%}
3+
{% set transfers_ethereum_erc20_agg_hour %}
4+
OPTIMIZE transfers_ethereum.erc20_agg_hour;
5+
{% endset %}
6+
7+
{% set transfers_ethereum_erc20_agg_day %}
8+
OPTIMIZE transfers_ethereum.erc20_agg_day;
9+
{% endset %}
10+
11+
{% set opensea_ethereum_trades %}
12+
OPTIMIZE opensea_ethereum.trades;
13+
{% endset %}
14+
15+
{% set opensea_solana_trades %}
16+
OPTIMIZE opensea_solana.trades;
17+
{% endset %}
18+
19+
{% set magiceden_solana_trades %}
20+
OPTIMIZE magiceden_solana.trades;
21+
{% endset %}
22+
23+
{% do run_query(transfers_ethereum_erc20_agg_hour) %}
24+
{% do run_query(transfers_ethereum_erc20_agg_day) %}
25+
{% do run_query(opensea_ethereum_trades) %}
26+
{% do run_query(opensea_solana_trades) %}
27+
{% do run_query(magiceden_solana_trades) %}
28+
29+
{% do log("Tables Optimized", info=True) %}
30+
{%- else -%}
31+
{%- endif -%}
32+
{% endmacro %}

0 commit comments

Comments
 (0)