table, tests, and descriptions (#16)

This commit is contained in:
Jessica Huhnke 2022-05-13 11:57:26 -05:00 committed by GitHub
parent 802cd33ef5
commit 7e36e0ad37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{% docs proposal_id %}
Numeric ID that corresponds to the proposal.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs proposal_type %}
The type of proposal that was submitted.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs proposer %}
The address of the validator that submitted the proposal.
{% enddocs %}

View File

@ -0,0 +1,71 @@
{{ config(
materialized = 'incremental',
unique_key = "tx_id",
incremental_strategy = 'delete+insert',
cluster_by = ['_ingested_at::DATE'],
) }}
WITH proposal_ids AS (
SELECT
tx_id,
attribute_value AS proposal_id
FROM {{ ref('silver__msg_attributes') }}
WHERE msg_type = 'submit_proposal'
AND attribute_key = 'proposal_id'
{% if is_incremental() %}
AND _ingested_at :: DATE >= CURRENT_DATE - 2
{% endif %}
),
proposal_type AS (
SELECT
tx_id,
attribute_value AS proposal_type
FROM {{ ref('silver__msg_attributes') }}
WHERE msg_type = 'submit_proposal'
AND attribute_key = 'proposal_type'
{% if is_incremental() %}
AND _ingested_at :: DATE >= CURRENT_DATE - 2
{% endif %}
),
proposer AS (
SELECT
tx_id,
split_part(attribute_value, '/', 0) as proposer
FROM {{ ref('silver__msg_attributes') }}
WHERE attribute_key = 'acc_seq'
{% if is_incremental() %}
AND _ingested_at :: DATE >= CURRENT_DATE - 2
{% endif %}
)
SELECT
block_id,
block_timestamp,
blockchain,
chain_id,
p.tx_id,
tx_status,
proposer,
p.proposal_id,
y.proposal_type,
_ingested_at
FROM proposal_ids p
INNER JOIN proposal_type y
ON p.tx_id = y.tx_id
INNER JOIN proposer pp
ON p.tx_id = pp.tx_id
LEFT OUTER JOIN {{ ref('silver__transactions') }} t
ON p.tx_id = t.tx_id
{% if is_incremental() %}
WHERE t._ingested_at :: DATE >= CURRENT_DATE - 2
{% endif %}

View File

@ -0,0 +1,59 @@
version: 2
models:
- name: silver__governance_submit_proposal
description: Records of all transactions that have occurred on Osmosis, dating back to the genesis block.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- TX_ID
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_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: BLOCKCHAIN
description: "{{ doc('blockchain') }}"
tests:
- not_null
- name: CHAIN_ID
description: "{{ doc('chain_id') }}"
tests:
- not_null
- name: TX_ID
description: "{{ doc('tx_id') }}"
tests:
- not_null
- name: TX_STATUS
description: "{{ doc('tx_status') }}"
tests:
- not_null
- name: PROPOSER
description: "{{ doc('tx_code') }}"
tests:
- not_null
- name: PROPOSAL_ID
description: "{{ doc('proposal_id') }}"
tests:
- not_null
- name: PROPOSAL_TYPE
description: "{{ doc('proposal_type') }}"
tests:
- not_null
- name: _INGESTED_AT
description: "{{ doc('ingested_at') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ