-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcf74c2
commit 77a7774
Showing
4 changed files
with
111 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
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ sources: | |
- name: raw_ton_gas | ||
- name: raw_ton_revenue | ||
- name: raw_ton_txns | ||
- name: raw_ton_dex_volumes |
80 changes: 80 additions & 0 deletions
80
models/staging/ton/_test_fact_ton_daa_txns_gas_gas_usd_revenue_revenue_native.yml
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,80 @@ | ||
models: | ||
- name: fact_ton_daa_txns_gas_gas_usd_revenue_revenue_native | ||
tests: | ||
- "dbt_expectations.expect_table_row_count_to_be_between:": | ||
min_value: 1 | ||
max_value: 1000000 | ||
columns: | ||
- name: CHAIN | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_to_exist | ||
- name: txns | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_to_exist | ||
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: | ||
date_column_name: DATE | ||
period: day | ||
lookback_periods: 1 | ||
trend_periods: 14 | ||
test_periods: 28 | ||
sigma_threshold: 3 | ||
take_logs: true | ||
severity: warn | ||
- name: dau | ||
tests: | ||
- dbt_expectations.expect_column_to_exist | ||
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: | ||
date_column_name: DATE | ||
period: day | ||
lookback_periods: 1 | ||
trend_periods: 14 | ||
test_periods: 28 | ||
sigma_threshold: 3 | ||
take_logs: true | ||
severity: warn | ||
- name: date | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_to_exist | ||
- dbt_expectations.expect_row_values_to_have_recent_data: | ||
datepart: day | ||
interval: 3 | ||
severity: warn | ||
- name: revenue | ||
tests: | ||
- dbt_expectations.expect_column_to_exist | ||
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: | ||
date_column_name: DATE | ||
period: day | ||
lookback_periods: 1 | ||
trend_periods: 14 | ||
test_periods: 28 | ||
sigma_threshold: 3 | ||
take_logs: true | ||
severity: warn | ||
- name: fees | ||
tests: | ||
- dbt_expectations.expect_column_to_exist | ||
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: | ||
date_column_name: DATE | ||
period: day | ||
lookback_periods: 1 | ||
trend_periods: 14 | ||
test_periods: 28 | ||
sigma_threshold: 3 | ||
take_logs: true | ||
severity: warn | ||
- name: fees_native | ||
tests: | ||
- dbt_expectations.expect_column_to_exist | ||
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: | ||
date_column_name: DATE | ||
period: day | ||
lookback_periods: 1 | ||
trend_periods: 14 | ||
test_periods: 28 | ||
sigma_threshold: 3 | ||
take_logs: true | ||
severity: warn |
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,22 @@ | ||
with | ||
max_extraction as ( | ||
select | ||
max(extraction_date) as max_extraction, | ||
value:date::date as date | ||
from landing_database.prod_landing.raw_ton_dex_volumes, | ||
lateral flatten(input => source_json) | ||
group by date | ||
), | ||
flattened_data as ( | ||
select value:"date"::date as date, value:"dex_volumes"::float as dex_volumes, extraction_date | ||
from landing_database.prod_landing.raw_ton_dex_volumes, | ||
lateral flatten(input => source_json) | ||
), | ||
prices as ({{ get_coingecko_price_with_latest("the-open-network") }}) | ||
select | ||
t1.date, | ||
'ton' as chain, | ||
dex_volumes * price as dex_volumes | ||
from flattened_data t1 | ||
inner join max_extraction t2 on t1.date = t2.date and t1.extraction_date = t2.max_extraction | ||
left join prices on t1.date = prices.date |