docs and core

This commit is contained in:
Jack Forgash 2022-07-29 17:02:51 -06:00
parent 2eefd48018
commit 254c9c7fd3
11 changed files with 223 additions and 1 deletions

View File

@ -0,0 +1,27 @@
{{ config(
materialized = 'view',
secure = true
) }}
WITH oracle_prices AS (
SELECT
block_timestamp AS TIMESTAMP,
token,
symbol,
token_contract,
price_usd,
source
FROM
{{ ref('silver__prices_oracle') }}
),
FINAL AS (
SELECT
*
FROM
oracle_prices
)
SELECT
*
FROM
FINAL

View File

@ -0,0 +1,63 @@
version: 2
models:
- name: core__fact_prices
description: |-
This table presents asset prices for the NEAR blockchain from various sources. Presently, only the on-chain oracle is provide.
columns:
- name: TIMESTAMP
description: "{{ doc('timestamp')}}"
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: TOKEN
description: "{{ doc('token')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: SYMBOL
description: "{{ doc('symbol')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: TOKEN_CONTRACT
description: "{{ doc('token_contract')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: PRICE_USD
description: "{{ doc('price_usd')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- FLOAT
- DOUBLE
- name: SOURCE
description: "{{ doc('source')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR

View File

@ -0,0 +1,5 @@
{% docs index %}
The positon index for the record in question, if it was stored in a particular order.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs price_usd %}
The asset price, in US Dollars.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs source %}
The source of the information presented in the record.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs symbol %}
The shorthand symbol for the token, as used by common price feeds and exchanges.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs timestamp %}
The date and time for the record.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs token %}
The long-form name of the token.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs token_contract %}
The contract address corresponding to the token, view details of the contract by following this address on the chain explorer.
{% enddocs %}

View File

@ -53,7 +53,7 @@ prices AS (
INDEX,
VALUE :asset_id :: STRING AS token_contract,
CASE
WHEN asset_id = 'aurora' THEN VALUE :price :multiplier :: DOUBLE / pow (
WHEN token_contract = 'aurora' THEN VALUE :price :multiplier :: DOUBLE / pow (
10,
7
)

View File

@ -0,0 +1,97 @@
version: 2
models:
- name: silver__prices_oracle
description: |-
This table parses messages from the contract `priceoracle.near` and extracts the available price data.
columns:
- name: BLOCK_ID
description: "{{ doc('block_id')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: BLOCK_TIMESTAMP
description: "{{ doc('block_timestamp')}}"
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: TX_HASH
description: "{{ doc('tx_hash')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: INDEX
description: "{{ doc('index')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: TOKEN
description: "{{ doc('token')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: SYMBOL
description: "{{ doc('symbol')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: TOKEN_CONTRACT
description: "{{ doc('token_contract')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: PRICE_USD
description: "{{ doc('price_usd')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- FLOAT
- DOUBLE
- name: SOURCE
description: "{{ doc('source')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: _INSERTED_TIMESTAMP
description: "{{ doc('_inserted_timestamp')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ