mirror of
https://github.com/FlipsideCrypto/eclipse-models.git
synced 2026-02-06 11:06:43 +00:00
Core gold models (#22)
* core blocks * core transactions * remove comments * core events * core events_inner * core transfers * core votes * recency tests * remove records with null block timestamps from core votes * use var not subquery * fix modified timestamp test * add search optimization * made inserted/modified timestamp cols sysdate * remove copypasta * add table descriptions --------- Co-authored-by: desmond-hui <desmond@flipsidecryto.com>
This commit is contained in:
parent
c7a211de6e
commit
90714d0ae7
40
models/gold/core/core__fact_blocks.sql
Normal file
40
models/gold/core/core__fact_blocks.sql
Normal file
@ -0,0 +1,40 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "block_id",
|
||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
full_refresh = false,
|
||||
tags = ['scheduled_core'],
|
||||
) }}
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set max_modified_query %}
|
||||
SELECT
|
||||
MAX(modified_timestamp) AS modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
{% set max_modified_timestamp = run_query(max_modified_query)[0][0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
network,
|
||||
chain_id,
|
||||
block_height,
|
||||
block_hash,
|
||||
previous_block_id,
|
||||
previous_block_hash,
|
||||
blocks_id AS fact_blocks_id,
|
||||
sysdate() AS inserted_timestamp,
|
||||
sysdate() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__blocks') }}
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
67
models/gold/core/core__fact_blocks.yml
Normal file
67
models/gold/core/core__fact_blocks.yml
Normal file
@ -0,0 +1,67 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_blocks
|
||||
description: Contains general information about each block produced on Eclipse.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: modified_timestamp >= current_date - 7
|
||||
columns:
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- unique
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: NETWORK
|
||||
description: Eclipse network name
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: CHAIN_ID
|
||||
description: chain identifier, this will always be eclipse. Field is used in joins with crosschain tables
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: BLOCK_HEIGHT
|
||||
description: Height of the block
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: BLOCK_HASH
|
||||
description: Hash of the block
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: PREVIOUS_BLOCK_ID
|
||||
description: previous slot value
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: PREVIOUS_BLOCK_HASH
|
||||
description: Previous block's hash value
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: FACT_BLOCKS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null
|
||||
43
models/gold/core/core__fact_events.sql
Normal file
43
models/gold/core/core__fact_events.sql
Normal file
@ -0,0 +1,43 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['block_id','tx_id','index'],
|
||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = ['block_timestamp::DATE','program_id'],
|
||||
post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id, program_id, event_type, inner_instruction_program_ids)'),
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set max_modified_query %}
|
||||
SELECT
|
||||
MAX(modified_timestamp) AS modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
{% set max_modified_timestamp = run_query(max_modified_query)[0][0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
signers,
|
||||
succeeded,
|
||||
index,
|
||||
program_id,
|
||||
event_type,
|
||||
instruction,
|
||||
inner_instruction,
|
||||
inner_instruction_program_ids,
|
||||
events_id AS fact_events_id,
|
||||
sysdate() AS inserted_timestamp,
|
||||
sysdate() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__events') }}
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
83
models/gold/core/core__fact_events.yml
Normal file
83
models/gold/core/core__fact_events.yml
Normal file
@ -0,0 +1,83 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_events
|
||||
description: Contains each event that occurs on Eclipse. A transaction can consist of more than one event.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: modified_timestamp >= current_date - 7
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_ID
|
||||
- INDEX
|
||||
where: block_timestamp::date > current_date - 30
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SIGNERS
|
||||
description: "{{ doc('signers') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INDEX
|
||||
description: "{{ doc('event_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: EVENT_TYPE
|
||||
description: "{{ doc('event_type') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INSTRUCTION
|
||||
description: "{{ doc('instruction') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INNER_INSTRUCTION
|
||||
description: "{{ doc('inner_instruction') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INNER_INSTRUCTION_PROGRAM_IDS
|
||||
description: "{{ doc('inner_instruction_program_ids') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: FACT_EVENTS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null
|
||||
44
models/gold/core/core__fact_events_inner.sql
Normal file
44
models/gold/core/core__fact_events_inner.sql
Normal file
@ -0,0 +1,44 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['block_id','tx_id','instruction_index','inner_index'],
|
||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = ['block_timestamp::DATE','program_id'],
|
||||
post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id, program_id, event_type, instruction_program_id)'),
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set max_modified_query %}
|
||||
SELECT
|
||||
MAX(modified_timestamp) AS modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
{% set max_modified_timestamp = run_query(max_modified_query)[0][0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
signers,
|
||||
succeeded,
|
||||
instruction_index,
|
||||
inner_index,
|
||||
instruction_program_id,
|
||||
program_id,
|
||||
event_type,
|
||||
instruction,
|
||||
_inserted_timestamp,
|
||||
events_inner_id AS fact_events_inner_id,
|
||||
sysdate() AS inserted_timestamp,
|
||||
sysdate() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__events_inner') }}
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
89
models/gold/core/core__fact_events_inner.yml
Normal file
89
models/gold/core/core__fact_events_inner.yml
Normal file
@ -0,0 +1,89 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_events_inner
|
||||
description: Contains each inner event that occurs on Eclipse. An event can consist of more than one inner event.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: modified_timestamp >= current_date - 7
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_ID
|
||||
- INSTRUCTION_INDEX
|
||||
- INNER_INDEX
|
||||
where: block_timestamp::date > current_date - 30
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SIGNERS
|
||||
description: "{{ doc('signers') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSTRUCTION_INDEX
|
||||
description: "{{ doc('event_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INNER_INDEX
|
||||
description: "{{ doc('inner_instruction_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSTRUCTION_PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}. For the instruction calling this inner instruction."
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: EVENT_TYPE
|
||||
description: "{{ doc('event_type') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INSTRUCTION
|
||||
description: "{{ doc('instruction') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null
|
||||
- name: FACT_EVENTS_INNER_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null
|
||||
54
models/gold/core/core__fact_transactions.sql
Normal file
54
models/gold/core/core__fact_transactions.sql
Normal file
@ -0,0 +1,54 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "tx_id",
|
||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id)'),
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set max_modified_query %}
|
||||
SELECT
|
||||
MAX(modified_timestamp) AS modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
{% set max_modified_timestamp = run_query(max_modified_query)[0][0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
index,
|
||||
recent_block_hash,
|
||||
signers,
|
||||
fee,
|
||||
succeeded,
|
||||
account_keys,
|
||||
pre_balances,
|
||||
post_balances,
|
||||
pre_token_balances,
|
||||
post_token_balances,
|
||||
instructions,
|
||||
inner_instructions,
|
||||
log_messages,
|
||||
address_table_lookups,
|
||||
units_consumed,
|
||||
units_limit,
|
||||
tx_size,
|
||||
version,
|
||||
transactions_id AS fact_transactions_id,
|
||||
sysdate() AS inserted_timestamp,
|
||||
sysdate() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
WHERE
|
||||
block_timestamp IS NOT NULL
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
121
models/gold/core/core__fact_transactions.yml
Normal file
121
models/gold/core/core__fact_transactions.yml
Normal file
@ -0,0 +1,121 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_transactions
|
||||
description: A table that contains high level information about every transaction on the Eclipse blockchain.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: modified_timestamp >= current_date - 7
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: RECENT_BLOCK_HASH
|
||||
description: "{{ doc('previous_block_hash') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- unique
|
||||
- name: INDEX
|
||||
description: "{{ doc('tx_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: FEE
|
||||
description: "{{ doc('tx_fee') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SIGNERS
|
||||
description: "{{ doc('signers') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: ACCOUNT_KEYS
|
||||
description: "{{ doc('tx_account_keys') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: PRE_BALANCES
|
||||
description: "{{ doc('pre_balances') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: POST_BALANCES
|
||||
description: "{{ doc('post_balances') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: PRE_TOKEN_BALANCES
|
||||
description: "{{ doc('pre_token_balances') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: POST_TOKEN_BALANCES
|
||||
description: "{{ doc('post_token_balances') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INSTRUCTIONS
|
||||
description: "{{ doc('instruction') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INNER_INSTRUCTIONS
|
||||
description: "{{ doc('inner_instruction') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: LOG_MESSAGES
|
||||
description: "{{ doc('log_messages') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: ADDRESS_TABLE_LOOKUPS
|
||||
description: "{{ doc('address_table_lookups') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: UNITS_CONSUMED
|
||||
description: "{{ doc('tx_units_consumed') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: UNITS_LIMIT
|
||||
description: "{{ doc('tx_unit_limit') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_SIZE
|
||||
description: "{{ doc('tx_size') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: VERSION
|
||||
description: "{{ doc('tx_version') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: FACT_TRANSACTIONS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null
|
||||
47
models/gold/core/core__fact_transfers.sql
Normal file
47
models/gold/core/core__fact_transfers.sql
Normal file
@ -0,0 +1,47 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ["fact_transfers_id"],
|
||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id, program_id, tx_from, tx_to, mint, fact_transfers_id)'),
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set max_modified_query %}
|
||||
SELECT
|
||||
MAX(modified_timestamp) AS modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
{% set max_modified_timestamp = run_query(max_modified_query)[0][0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
succeeded,
|
||||
index,
|
||||
inner_index,
|
||||
program_id,
|
||||
tx_from,
|
||||
tx_to,
|
||||
mint,
|
||||
amount,
|
||||
decimal,
|
||||
source_token_account,
|
||||
dest_token_account,
|
||||
_inserted_timestamp,
|
||||
transfers_id AS fact_transfers_id,
|
||||
sysdate() AS inserted_timestamp,
|
||||
sysdate() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__transfers') }}
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
94
models/gold/core/core__fact_transfers.yml
Normal file
94
models/gold/core/core__fact_transfers.yml
Normal file
@ -0,0 +1,94 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_transfers
|
||||
description: Contains transfer events for Eclipse and spl-tokens.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: modified_timestamp >= current_date - 7
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_ID
|
||||
- INDEX
|
||||
- INNER_INDEX
|
||||
where: block_timestamp::date > current_date - 30
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INDEX
|
||||
description: "{{ doc('event_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INNER_INDEX
|
||||
description: "{{ doc('inner_instruction_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_FROM
|
||||
description: "{{ doc('tx_from') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_TO
|
||||
description: "{{ doc('tx_to') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: MINT
|
||||
description: "{{ doc('mint') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null:
|
||||
config:
|
||||
where: >
|
||||
_inserted_timestamp >= current_date - 7
|
||||
AND succeeded
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('amount') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: DECIMAL
|
||||
description: "{{ doc('decimal') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: FACT_TRANSFERS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
data_tests:
|
||||
- not_null: *recent_date_filter
|
||||
- unique
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
data_tests:
|
||||
- not_null: *recent_date_filter
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
data_tests:
|
||||
- not_null
|
||||
47
models/gold/core/core__fact_votes.sql
Normal file
47
models/gold/core/core__fact_votes.sql
Normal file
@ -0,0 +1,47 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['tx_id','vote_index'],
|
||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id)'),
|
||||
tags = ['scheduled_core']
|
||||
) }}
|
||||
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set max_modified_query %}
|
||||
SELECT
|
||||
MAX(modified_timestamp) AS modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
{% set max_modified_timestamp = run_query(max_modified_query)[0][0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
index,
|
||||
recent_block_hash,
|
||||
signers,
|
||||
fee,
|
||||
succeeded,
|
||||
account_keys,
|
||||
vote_index,
|
||||
event_type,
|
||||
instruction,
|
||||
version,
|
||||
votes_id AS fact_votes_id,
|
||||
sysdate() AS inserted_timestamp,
|
||||
sysdate() AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__votes') }}
|
||||
WHERE
|
||||
block_timestamp IS NOT NULL
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
90
models/gold/core/core__fact_votes.yml
Normal file
90
models/gold/core/core__fact_votes.yml
Normal file
@ -0,0 +1,90 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_votes
|
||||
description: A table that contains high level information about native vote program events on the Eclipse blockchain.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: modified_timestamp >= current_date - 7
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: RECENT_BLOCK_HASH
|
||||
description: Previous block's hash value
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- unique:
|
||||
config:
|
||||
where: >
|
||||
block_timestamp::date > current_date - 30
|
||||
- name: INDEX
|
||||
description: "{{ doc('tx_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: FEE
|
||||
description: Transaction fee (in lamports)
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: SIGNERS
|
||||
description: "{{ doc('signers') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: ACCOUNT_KEYS
|
||||
description: "{{ doc('tx_account_keys') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: VOTE_INDEX
|
||||
description: "{{ doc('vote_index') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: EVENT_TYPE
|
||||
description: "{{ doc('vote_event_type') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSTRUCTION
|
||||
description: "{{ doc('vote_instruction') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- not_null: *recent_date_filter
|
||||
- name: VERSION
|
||||
description: "{{ doc('tx_version') }}"
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: FACT_VOTES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
data_tests:
|
||||
- not_null: *recent_date_filter
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
data_tests:
|
||||
- not_null: *recent_date_filter
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
data_tests:
|
||||
- not_null
|
||||
Loading…
Reference in New Issue
Block a user