-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add macro and airdrop addresses to staging (#1688)
* add sql * update logic * format
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Generate a range of numbers | ||
{% macro generate_range(start, end) %} | ||
{% set range_list = [] %} | ||
{% for i in range(start, end + 1) %} | ||
{% do range_list.append(i) %} | ||
{% endfor %} | ||
{{ return(range_list) }} | ||
{% endmacro %} | ||
|
||
{% macro combine_op_airdrops(suffixes) %} | ||
|
||
{% set queries = [] %} | ||
|
||
-- Loop through each suffix and generate the full table reference | ||
{% for suffix in suffixes %} | ||
{% set table_name = 'op_airdrop' ~ suffix ~ '_addresses_detailed_list' %} | ||
{% set query = "select address, op_amount_raw/1e18 as op_amount, cast('" ~ suffix ~ "' as int) as airdrop_round from " ~ source('static_data_sources', table_name) %} | ||
{% do queries.append(query) %} | ||
{% endfor %} | ||
|
||
{# Join all queries with UNION ALL #} | ||
{{ return(queries | join(' UNION ALL\n')) }} | ||
|
||
{% endmacro %} |
16 changes: 16 additions & 0 deletions
16
warehouse/dbt/models/staging/optimism/stg_optimism_airdrop_addresses.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{ config( | ||
materialized='table', | ||
partition_by={ | ||
"field": "airdrop_round", | ||
"data_type": "int64", | ||
"range": { | ||
"start": 0, | ||
"end": 100, | ||
"interval": 10 | ||
} | ||
} | ||
) }} | ||
|
||
{{ | ||
combine_op_airdrops(generate_range(1, 4)) | ||
}} |
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