Skip to content

Commit

Permalink
Add macro and airdrop addresses to staging (#1688)
Browse files Browse the repository at this point in the history
* add sql

* update logic

* format
  • Loading branch information
chuxinh authored Jun 21, 2024
1 parent 3c7e79c commit e984650
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
24 changes: 24 additions & 0 deletions warehouse/dbt/macros/models/combine_op_airdrops.sql
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 %}
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))
}}
14 changes: 13 additions & 1 deletion warehouse/dbt/models/static_data_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ sources:
identifier: agora_rf4_repos_with_contracts
- name: op_airdrop1_addresses_detailed_list
identifier: op_airdrop1_addresses_detailed_list
columns:
- name: address
data_type: string
- name: op_airdrop2_addresses_detailed_list
identifier: op_airdrop2_addresses_detailed_list
columns:
- name: address
data_type: string
- name: op_airdrop3_addresses_detailed_list
identifier: op_airdrop3_addresses_detailed_list
columns:
- name: address
data_type: string
- name: op_airdrop4_addresses_detailed_list
identifier: op_airdrop4_addresses_detailed_list
identifier: op_airdrop4_addresses_detailed_list
columns:
- name: address
data_type: string

0 comments on commit e984650

Please sign in to comment.