An 2544/dim labels models (#79)

* wip

* dim models done

* fix merge conflicts

* dox
This commit is contained in:
Jessica Huhnke 2022-12-08 18:13:48 +00:00 committed by GitHub
parent 92ee159289
commit e1145d9200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 300 additions and 16 deletions

1
docs/catalog.json Normal file

File diff suppressed because one or more lines are too long

1
docs/manifest.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
{{ config(
materialized = 'view'
) }}
SELECT
'osmosis' AS blockchain,
module,
pool_id,
assets
FROM {{ ref('silver__pool_metadata') }}

View File

@ -0,0 +1,21 @@
version: 2
models:
- name: core__dim_liquidity_pools
description: Contains liquidity pool metadata for assets on the Osmosis blockchain. This table was sourced from an API and may not contain every token.
columns:
- name: BLOCKCHAIN
description: "{{ doc('blockchain') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: MODULE
description: "{{ doc('pool_module') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: POOL_ID
description: "{{ doc('pool_id') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: ASSETS
description: "{{ doc('pool_assets') }}"
tests:
- dbt_expectations.expect_column_to_exist

View File

@ -0,0 +1,16 @@
{{ config(
materialized = 'view'
) }}
SELECT
blockchain,
address,
creator,
label_type,
label_subtype,
label,
project_name,
alias,
decimal,
raw_metadata
FROM {{ ref('silver__asset_metadata') }}

View File

@ -0,0 +1,45 @@
version: 2
models:
- name: core__dim_tokens
description: Contains token metadata for assets on the Osmosis blockchain. This table was sourced from an API and may not contain every token.
columns:
- name: ADDRESS
description: "{{ doc('address') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: BLOCKCHAIN
description: "{{ doc('blockchain') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: CREATOR
description: "{{ doc('creator') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: LABEL_TYPE
description: "{{ doc('label_type') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: LABEL_SUBTYPE
description: "{{ doc('label_subtype') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: LABEL
description: "{{ doc('label') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: PROJECT_NAME
description: "{{ doc('project_name') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: ALIAS
description: A secondary address for the token, where available
tests:
- dbt_expectations.expect_column_to_exist
- name: DECIMAL
description: "{{ doc('decimal') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: RAW_METADATA
description: "{{ doc('raw_metadata') }}"
tests:
- dbt_expectations.expect_column_to_exist

View File

@ -0,0 +1,23 @@
{{ config(
materialized = 'view'
) }}
SELECT
address,
blockchain,
creator,
label_type,
label_subtype,
label,
project_name,
account_address,
delegator_shares,
jailed,
max_change_rate,
max_rate,
min_self_delegation,
RANK,
missed_blocks,
raw_metadata
FROM
{{ ref('silver__validator_metadata') }}

View File

@ -0,0 +1,69 @@
version: 2
models:
- name: core__fact_validators
description: Contains validator metadata for assets on the Osmosis blockchain. This table was sourced from an API and may not contain every token.
columns:
- name: ADDRESS
description: "{{ doc('address') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: BLOCKCHAIN
description: "{{ doc('blockchain') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: CREATOR
description: "{{ doc('creator') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: LABEL_TYPE
description: "{{ doc('label_type') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: LABEL_SUBTYPE
description: "{{ doc('label_subtype') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: LABEL
description: "{{ doc('label') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: PROJECT_NAME
description: "{{ doc('project_name') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: ACCOUNT_ADDRESS
description: The osmosis address of the user / entity that operates the validator.
tests:
- dbt_expectations.expect_column_to_exist
- name: DELEGATOR_SHARES
description: The number of tokens staked to the validator.
tests:
- dbt_expectations.expect_column_to_exist
- name: JAILED
description: FALSE when a validator is not jailed, TRUE when a validator is jailed
tests:
- dbt_expectations.expect_column_to_exist
- name: MAX_CHANGE_RATE
description: The maximum rate at which a validator can change their commission per day.
tests:
- dbt_expectations.expect_column_to_exist
- name: MAX_RATE
description: The maximum commission rate that the validator can charge
tests:
- dbt_expectations.expect_column_to_exist
- name: MIN_SELF_DELEGATION
description: The minimum number of OSMO tokens that the operator must be staking with their own validator
tests:
- dbt_expectations.expect_column_to_exist
- name: RANK
description: The rank of the validator in the validator set. Rank is determined by the number of OSMO tokens staked to the validator
tests:
- dbt_expectations.expect_column_to_exist
- name: MISSED_BLOCKS
description: The number of blocks the validator has been down for during it's lifetime.
tests:
- dbt_expectations.expect_column_to_exist
- name: RAW_METADATA
description: "{{ doc('raw_metadata') }}"
tests:
- dbt_expectations.expect_column_to_exist

View File

@ -28,10 +28,16 @@ SELECT
'token_contract' AS label_subtype,
label,
project_name,
raw_metadata
raw_metadata [0] :aliases [0] :: STRING AS alias,
raw_metadata [array_size(raw_metadata)-1] :exponent :: NUMBER AS DECIMAL,
raw_metadata,
concat_ws(
'-',
address,
creator,
blockchain
) AS _unique_key
FROM
base
qualify(ROW_NUMBER() over(PARTITION BY blockchain, creator, address
base qualify(ROW_NUMBER() over(PARTITION BY blockchain, creator, address
ORDER BY
project_name DESC)) = 1

View File

@ -4,9 +4,7 @@ models:
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCKCHAIN
- CREATOR
- ADDRESS
- _UNIQUE_KEY
columns:
- name: BLOCKCHAIN
description: "{{ doc('blockchain') }}"
@ -68,11 +66,22 @@ models:
column_type_list:
- STRING
- VARCHAR
- name: RAW_METADATA
description: "{{ doc('raw_metadata') }}"
- name: ALIAS
description: A secondary address for the token, where available
tests:
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: DECIMAL
description: "{{ doc('decimal') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- OBJECT
- ARRAY
- NUMBER
- FLOAT
- name: RAW_METADATA
description: "{{ doc('raw_metadata') }}"
tests:
- not_null

View File

@ -10,7 +10,21 @@ SELECT
'validator' AS label_subtype,
moniker AS label,
identity AS project_name,
VALUE AS raw_metadata
VALUE :account_address :: STRING AS account_address,
VALUE :delegator_shares :: NUMBER AS delegator_shares,
VALUE :jailed :: BOOLEAN AS jailed,
VALUE :max_change_rate :: NUMBER AS max_change_rate,
VALUE :max_rate :: NUMBER AS max_rate,
VALUE :min_self_delegation :: NUMBER AS min_self_delegation,
VALUE :rank :: NUMBER AS RANK,
VALUE :uptime :missed_blocks :: NUMBER AS missed_blocks,
VALUE AS raw_metadata,
concat_ws(
'-',
address,
creator,
blockchain
) AS _unique_key
FROM
{{ source(
'osmosis_external',

View File

@ -4,9 +4,7 @@ models:
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- CREATOR
- ADDRESS
- BLOCKCHAIN
- _UNIQUE_KEY
columns:
- name: ADDRESS
description: "{{ doc('address') }}"
@ -70,7 +68,78 @@ models:
column_type_list:
- STRING
- VARCHAR
- name: ACCOUNT_ADDRESS
description: The osmosis address of the user / entity that operates the validator.
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: DELEGATOR_SHARES
description: The number of tokens staked to the validator.
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: JAILED
description: FALSE when a validator is not jailed, TRUE when a validator is jailed
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- BOOLEAN
- name: MAX_CHANGE_RATE
description: The maximum rate at which a validator can change their commission per day.
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: MAX_RATE
description: The maximum commission rate that the validator can charge
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: MIN_SELF_DELEGATION
description: The minimum number of OSMO tokens that the operator must be staking with their own validator
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: RANK
description: The rank of the validator in the validator set. Rank is determined by the number of OSMO tokens staked to the validator
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: MISSED_BLOCKS
description: The number of blocks the validator has been down for during it's lifetime.
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: RAW_METADATA
description: "{{ doc('raw_metadata') }}"
tests:
- not_null
- not_null
- name: _UNIQUE_KEY
description: The unique key of the table
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR