yml and core views

This commit is contained in:
Jack Forgash 2023-02-23 13:29:48 -07:00
parent e66c14e24e
commit 727787868a
19 changed files with 354 additions and 6 deletions

View File

@ -0,0 +1,14 @@
{{ config(
materialized = 'view',
tags = ['s3_curated', 'social']
) }}
SELECT
action_id,
tx_hash,
block_id,
block_timestamp,
allowance,
signer_id
FROM
{{ ref('silver_social__addkey') }}

View File

@ -0,0 +1,26 @@
version: 2
models:
- name: social__fact_addkey_events
description: |-
All AddKey events for the contract social.near, which indicate a wallet or user authorizing use of the contract as a high-level proxy for interest in the platform.
columns:
- name: ACTION_ID
description: "{{ doc('block_id')}}"
- name: TX_HASH
description: "{{ doc('tx_hash')}}"
- name: BLOCK_ID
description: "{{ doc('block_id')}}"
- name: BLOCK_TIMESTAMP
description: "{{ doc('block_timestamp')}}"
- name: ALLOWANCE
description: "{{ doc('allowance')}}"
- name: SIGNER_ID
description: "{{ doc('signer_id')}}"

View File

@ -0,0 +1,14 @@
{{ config(
materialized = 'view',
tags = ['s3_curated', 'social']
) }}
SELECT
action_id_social,
tx_hash,
block_id,
block_timestamp,
node,
node_data
FROM
{{ ref('silver_social__decoded_actions') }}

View File

@ -0,0 +1,29 @@
version: 2
models:
- name: social__fact_decoded_actions
description: |-
Decoded FunctionCall events for receipts where the contract social.near was called.
columns:
- name: ACTION_ID_SOCIAL
description: "{{ doc('block_id')}}"
- name: TX_HASH
description: "{{ doc('tx_hash')}}"
- name: BLOCK_ID
description: "{{ doc('block_id')}}"
- name: BLOCK_TIMESTAMP
description: "{{ doc('block_timestamp')}}"
- name: SIGNER_ID
description: "{{ doc('signer_id')}}"
- name: NODE
description: "{{ doc('node')}}"
- name: NODE_DATA
description: "{{ doc('node_data')}}"

View File

@ -0,0 +1,15 @@
{{ config(
materialized = 'view',
tags = ['s3_curated', 'social']
) }}
SELECT
action_id_profile,
tx_hash,
block_id,
block_timestamp,
signer_id,
profile_section,
profile_data
FROM
{{ ref('silver_social__profile_changes') }}

View File

@ -0,0 +1,29 @@
version: 2
models:
- name: social__fact_profile_changes
description: |-
Events from the node `profile` that indicate a change to a user's profile.
columns:
- name: ACTION_ID_PROFILE
description: "{{ doc('block_id')}}"
- name: TX_HASH
description: "{{ doc('tx_hash')}}"
- name: BLOCK_ID
description: "{{ doc('block_id')}}"
- name: BLOCK_TIMESTAMP
description: "{{ doc('block_timestamp')}}"
- name: SIGNER_ID
description: "{{ doc('signer_id')}}"
- name: PROFILE_SECTION
description: "{{ doc('profile_section')}}"
- name: PROFILE_DATA
description: "{{ doc('profile_data')}}"

View File

@ -0,0 +1,5 @@
{% docs _source %}
An internal column denoting the source of the data.
{% enddocs %}

View File

@ -0,0 +1,7 @@
{% docs node %}
A branch of the data object.
In the case of NEAR Social schema, node is being used to denote the top-level key of the data object.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs node_data %}
The data object that the top level node contains.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs profile_data %}
The data being updated for the profile section in the transaction.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs profile_section %}
The section of the profile that is being edited in the transaction.
{% enddocs %}

View File

@ -2,7 +2,7 @@
materialized = 'incremental',
unique_key = 'action_id',
cluster_by = ['block_timestamp::date'],
tags = ['s3_curated']
tags = ['s3_curated', 'social']
) }}
WITH receipts AS (

View File

@ -0,0 +1,35 @@
version: 2
models:
- name: silver_social__addkey
description: |-
All AddKey events for the contract social.near, which indicate a wallet or user authorizing use of the contract as a high-level proxy for interest in the platform.
columns:
- name: action_id
description: "{{ doc('block_id')}}"
- name: tx_hash
description: "{{ doc('tx_hash')}}"
- name: block_id
description: "{{ doc('block_id')}}"
- name: block_timestamp
description: "{{ doc('block_timestamp')}}"
- name: allowance
description: "{{ doc('allowance')}}"
- name: signer_id
description: "{{ doc('signer_id')}}"
- name: _source
description: "{{ doc('_source')}}"
- name: _partition_by_block_number
description: "{{ doc('_partition_by_block_number')}}"
- name: _load_timestamp
description: "{{ doc('_load_timestamp')}}"

View File

@ -2,7 +2,7 @@
materialized = 'incremental',
unique_key = 'action_id_social',
cluster_by = ['_load_timestamp::date', '_partition_by_block_number'],
tags = ['s3_curated']
tags = ['s3_curated', 'social']
) }}
WITH all_social_receipts AS (
@ -98,7 +98,7 @@ flattened_actions AS (
block_timestamp,
signer_id,
key AS node,
VALUE AS node_value,
VALUE AS node_data,
_load_timestamp,
_partition_by_block_number
FROM

View File

@ -0,0 +1,52 @@
version: 2
models:
- name: silver_social__decoded_actions
description: |-
Decoded FunctionCall events for receipts where the contract social.near was called.
columns:
- name: action_id_social
description: "{{ doc('block_id')}}"
- name: tx_hash
description: "{{ doc('tx_hash')}}"
- name: block_id
description: "{{ doc('block_id')}}"
- name: block_timestamp
description: "{{ doc('block_timestamp')}}"
- name: signer_id
description: "{{ doc('signer_id')}}"
tests:
- not_null
- name: node
description: "{{ doc('node')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- varchar
- name: node_data
description: "{{ doc('node_data')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- object
- variant
- name: _partition_by_block_number
description: "{{ doc('_partition_by_block_number')}}"
- name: _load_timestamp
description: "{{ doc('_load_timestamp')}}"
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 2

View File

@ -2,7 +2,7 @@
materialized = 'incremental',
unique_key = 'action_id_profile',
cluster_by = ['block_timestamp::date', 'signer_id'],
tags = ['s3_curated']
tags = ['s3_curated', 'social']
) }}
WITH decoded_actions AS (
@ -38,7 +38,7 @@ flatten_profile_json AS (
_partition_by_block_number
FROM
decoded_actions,
LATERAL FLATTEN(node_value)
LATERAL FLATTEN(node_data)
)
SELECT
action_id_profile,

View File

@ -0,0 +1,45 @@
version: 2
models:
- name: silver_social__profile_changes
description: |-
Events from the node `profile` that indicate a change to a user's profile.
columns:
- name: action_id_profile
description: "{{ doc('block_id')}}"
- name: tx_hash
description: "{{ doc('tx_hash')}}"
- name: block_id
description: "{{ doc('block_id')}}"
- name: block_timestamp
description: "{{ doc('block_timestamp')}}"
- name: signer_id
description: "{{ doc('signer_id')}}"
- name: profile_section
description: "{{ doc('profile_section')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- varchar
- name: profile_data
description: "{{ doc('profile_data')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- varchar
- name: _partition_by_block_number
description: "{{ doc('_partition_by_block_number')}}"
- name: _load_timestamp
description: "{{ doc('_load_timestamp')}}"

View File

@ -2,7 +2,7 @@
materialized = 'incremental',
unique_key = 'action_id',
cluster_by = ['_load_timestamp::date', '_partition_by_block_number'],
tags = ['s3_curated']
tags = ['s3_curated', 'social']
) }}
WITH all_social_receipts AS (

View File

@ -0,0 +1,62 @@
version: 2
models:
- name: silver_social__receipts
description: |-
Filtered receipts where the signer or receiver is the contract social.near.
columns:
- name: tx_hash
description: "{{ doc('tx_hash')}}"
- name: block_id
description: "{{ doc('block_id')}}"
- name: receipt_index
description: "{{ doc('receipt_index')}}"
- name: chunk_hash
description: "{{ doc('chunk_hash')}}"
- name: receipt_actions
description: "{{ doc('receipt')}}"
- name: execution_outcome
description: "{{ doc('execution_outcome')}}"
- name: receipt_object_id
description: "{{ doc('receipt_object_id')}}"
- name: receipt_outcome_id
description: "{{ doc('receipt_outcome_id')}}"
- name: receiver_id
description: "{{ doc('receiver_id')}}"
- name: signer_id
description: "{{ doc('signer_id')}}"
- name: receipt_type
description: "{{ doc('receipt_type')}}"
- name: gas_burnt
description: "{{ doc('gas_burnt')}}"
- name: status_value
description: "{{ doc('status_value')}}"
- name: logs
description: "{{ doc('logs')}}"
- name: proof
description: "{{ doc('proof')}}"
- name: metadata
description: "{{ doc('metadata')}}"
- name: _load_timestamp
description: "{{ doc('_load_timestamp')}}"
- name: _partition_by_block_number
description: "{{ doc('_partition_by_block_number')}}"