diff --git a/models/descriptions/proposal_id.md b/models/descriptions/proposal_id.md new file mode 100644 index 0000000..5c355c2 --- /dev/null +++ b/models/descriptions/proposal_id.md @@ -0,0 +1,5 @@ +{% docs proposal_id %} + +Numeric ID that corresponds to the proposal. + +{% enddocs %} \ No newline at end of file diff --git a/models/descriptions/proposal_type.md b/models/descriptions/proposal_type.md new file mode 100644 index 0000000..7300147 --- /dev/null +++ b/models/descriptions/proposal_type.md @@ -0,0 +1,5 @@ +{% docs proposal_type %} + +The type of proposal that was submitted. + +{% enddocs %} \ No newline at end of file diff --git a/models/descriptions/proposer.md b/models/descriptions/proposer.md new file mode 100644 index 0000000..8cf193d --- /dev/null +++ b/models/descriptions/proposer.md @@ -0,0 +1,5 @@ +{% docs proposer %} + +The address of the validator that submitted the proposal. + +{% enddocs %} \ No newline at end of file diff --git a/models/silver/silver__governance_submit_proposal.sql b/models/silver/silver__governance_submit_proposal.sql new file mode 100644 index 0000000..412fa60 --- /dev/null +++ b/models/silver/silver__governance_submit_proposal.sql @@ -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 %} \ No newline at end of file diff --git a/models/silver/silver__governance_submit_proposal.yml b/models/silver/silver__governance_submit_proposal.yml new file mode 100644 index 0000000..8d4cb91 --- /dev/null +++ b/models/silver/silver__governance_submit_proposal.yml @@ -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 \ No newline at end of file