mirror of
https://github.com/FlipsideCrypto/terra-models.git
synced 2026-02-06 13:26:45 +00:00
commit
26dfd40f4b
21
models/core/core__fact_governance_votes.sql
Normal file
21
models/core/core__fact_governance_votes.sql
Normal file
@ -0,0 +1,21 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
with governance_votes as (
|
||||
select
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
voter,
|
||||
proposal_id,
|
||||
vote_option,
|
||||
vote_option_text,
|
||||
vote_weight,
|
||||
tx_succeeded
|
||||
from {{ ref('silver__governance_votes') }}
|
||||
)
|
||||
|
||||
select * from governance_votes
|
||||
126
models/core/core__fact_governance_votes.yml
Normal file
126
models/core/core__fact_governance_votes.yml
Normal file
@ -0,0 +1,126 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: core__fact_governance_votes
|
||||
description: |-
|
||||
This table contains votes cast on governance proposals.
|
||||
|
||||
columns:
|
||||
- name: tx_id
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('silver__transactions')
|
||||
field: tx_id
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: block_id
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('silver__blocks')
|
||||
field: block_id
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- 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
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'terra'
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: chain_id
|
||||
description: "{{ doc('chain_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'phoenix-1'
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: voter
|
||||
description: "{{ doc('voter') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: proposal_id
|
||||
description: "{{ doc('proposal_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- name: vote_option
|
||||
description: "{{ doc('vote_option') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 1
|
||||
max_value: 4
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- name: vote_option_text
|
||||
description: "{{ doc('vote_option_text') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'Yes'
|
||||
- 'Abstain'
|
||||
- 'No'
|
||||
- 'NoWithVeto'
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: vote_weight
|
||||
description: "{{ doc('vote_weight') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- name: tx_succeeded
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- boolean
|
||||
|
||||
5
models/descriptions/vote_option.md
Normal file
5
models/descriptions/vote_option.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs vote_option %}
|
||||
|
||||
The numerical vote option cast by the voter.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/vote_option_text.md
Normal file
5
models/descriptions/vote_option_text.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs vote_option_text %}
|
||||
|
||||
The human-readable vote option cast by the voter.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/vote_weight.md
Normal file
5
models/descriptions/vote_weight.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs vote_weight %}
|
||||
|
||||
The weight of the vote cast by the voter. For now, it's always a full vote: `1`.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/voter.md
Normal file
5
models/descriptions/voter.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs voter %}
|
||||
|
||||
The address of the validator or delegator who casted this vote.
|
||||
|
||||
{% enddocs %}
|
||||
61
models/silver/silver__governance_votes.sql
Normal file
61
models/silver/silver__governance_votes.sql
Normal file
@ -0,0 +1,61 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = 'tx_id',
|
||||
incremental_strategy = 'delete+insert'
|
||||
) }}
|
||||
|
||||
with base_votes as (
|
||||
select
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_succeeded,
|
||||
chain_id,
|
||||
attributes,
|
||||
_inserted_timestamp
|
||||
from {{ ref('silver__messages') }}
|
||||
where message_type = '/cosmos.gov.v1beta1.MsgVote'
|
||||
and {{ incremental_load_filter('_inserted_timestamp') }}
|
||||
),
|
||||
|
||||
parsed_votes as (
|
||||
select
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_succeeded,
|
||||
chain_id,
|
||||
attributes:message:sender::text as voter,
|
||||
attributes:proposal_vote:proposal_id::number as proposal_id,
|
||||
parse_json(attributes:proposal_vote:option) as parsed_vote_option,
|
||||
parsed_vote_option:option::number as vote_option,
|
||||
case vote_option
|
||||
when 1 then 'Yes'
|
||||
when 2 then 'Abstain'
|
||||
when 3 then 'No'
|
||||
when 4 then 'NoWithVeto'
|
||||
end as vote_option_text,
|
||||
parsed_vote_option:weight::number as vote_weight,
|
||||
'terra' as blockchain,
|
||||
_inserted_timestamp
|
||||
from base_votes
|
||||
),
|
||||
|
||||
final as (
|
||||
select
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
voter,
|
||||
proposal_id,
|
||||
vote_option,
|
||||
vote_option_text,
|
||||
vote_weight,
|
||||
tx_succeeded,
|
||||
_inserted_timestamp
|
||||
from parsed_votes
|
||||
)
|
||||
|
||||
select * from final
|
||||
133
models/silver/silver__governance_votes.yml
Normal file
133
models/silver/silver__governance_votes.yml
Normal file
@ -0,0 +1,133 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver__governance_votes
|
||||
description: |-
|
||||
This table contains votes cast on governance proposals.
|
||||
|
||||
columns:
|
||||
- name: tx_id
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('silver__transactions')
|
||||
field: tx_id
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: block_id
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('silver__blocks')
|
||||
field: block_id
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- 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
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'terra'
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: chain_id
|
||||
description: "{{ doc('chain_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'phoenix-1'
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: voter
|
||||
description: "{{ doc('voter') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: proposal_id
|
||||
description: "{{ doc('proposal_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- name: vote_option
|
||||
description: "{{ doc('vote_option') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 1
|
||||
max_value: 4
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- name: vote_option_text
|
||||
description: "{{ doc('vote_option_text') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'Yes'
|
||||
- 'Abstain'
|
||||
- 'No'
|
||||
- 'NoWithVeto'
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- string
|
||||
- varchar
|
||||
|
||||
- name: vote_weight
|
||||
description: "{{ doc('vote_weight') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- number
|
||||
|
||||
- name: tx_succeeded
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- boolean
|
||||
|
||||
- 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
|
||||
Loading…
Reference in New Issue
Block a user