Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stablecoins: make stablecoin tables incremental #474

Merged
merged 10 commits into from
Oct 1, 2024
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }}
{{ config(materialized="incremental", unique_key="unique_id", snowflake_warehouse="STABLECOIN_V2_LG") }}
select
date
, contract_address
Expand All @@ -18,5 +18,9 @@ select
, p2p_stablecoin_daily_txns
, stablecoin_supply
, is_wallet
, unique_id
, chain
from {{ ref("agg_daily_stablecoin_breakdown_silver") }}
from {{ ref("agg_daily_stablecoin_breakdown_silver") }}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,23 +1,71 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }}
{{ config(materialized="incremental", unique_key="unique_id", snowflake_warehouse="STABLECOIN_V2_LG") }}
with
daily_data as (
{{
dbt_utils.union_relations(
relations=[
ref("ez_base_stablecoin_metrics_by_address"),
ref("ez_arbitrum_stablecoin_metrics_by_address"),
ref("ez_optimism_stablecoin_metrics_by_address"),
ref("ez_avalanche_stablecoin_metrics_by_address"),
ref("ez_polygon_stablecoin_metrics_by_address"),
ref("ez_ethereum_stablecoin_metrics_by_address"),
ref("ez_solana_stablecoin_metrics_by_address"),
ref("ez_tron_stablecoin_metrics_by_address"),
ref("ez_bsc_stablecoin_metrics_by_address"),
ref("ez_ton_stablecoin_metrics_by_address"),
ref("ez_celo_stablecoin_metrics_by_address"),
]
)
}}
select *
from {{ref("ez_base_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_arbitrum_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_optimism_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_avalanche_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_polygon_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_ethereum_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_solana_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_tron_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_bsc_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_ton_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
union all
select *
from {{ref("ez_celo_stablecoin_metrics_by_address")}}
{% if is_incremental() %}
where date >= (select dateadd('day', -7, max(date)) from {{ this }})
{% endif %}
)
select
date
Expand Down
Loading