mirror of
https://github.com/FlipsideCrypto/movement-models.git
synced 2026-02-06 09:26:45 +00:00
.
This commit is contained in:
parent
1f82f36b9b
commit
f4ae71893d
2
.github/workflows/dbt_test_daily.yml
vendored
2
.github/workflows/dbt_test_daily.yml
vendored
@ -43,7 +43,7 @@ jobs:
|
|||||||
dbt deps
|
dbt deps
|
||||||
- name: Run DBT Jobs
|
- name: Run DBT Jobs
|
||||||
run: |
|
run: |
|
||||||
dbt test -m tag:test_recency tag:test_quality --vars '{"TEST_HOURS_THRESHOLD":24}'
|
dbt test -m tag:test_recency tag:test_quality --vars '{"TEST_HOURS_THRESHOLD":72}'
|
||||||
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','change_index'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
incremental_predicates = ["dynamic_range_predicate","block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ["inserted_timestamp"],
|
|
||||||
cluster_by = ['block_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash,change_type,inner_change_type,change_address,change_module,change_resource,payload_function);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash,change_type,inner_change_type,change_address,change_module,change_resource,payload_function);",
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = 'tx_hash',
|
unique_key = 'version',
|
||||||
incremental_strategy = 'delete+insert',
|
incremental_strategy = 'delete+insert',
|
||||||
cluster_by = ['block_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash,event_type,event_address,event_module,event_resource,payload_function);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash,event_type,event_address,event_module,event_resource,payload_function);",
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ["inserted_timestamp"],
|
|
||||||
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash,payload_function,sender);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash,payload_function,sender);",
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
incremental_predicates = ["dynamic_range_predicate","block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ['inserted_timestamp'],
|
merge_exclude_columns = ['inserted_timestamp'],
|
||||||
cluster_by = ['block_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash);",
|
||||||
@ -26,7 +25,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
previous_block_votes_bitvec,
|
previous_block_votes_bitvec,
|
||||||
proposer,
|
proposer,
|
||||||
round,
|
ROUND,
|
||||||
vm_status,
|
vm_status,
|
||||||
state_change_hash,
|
state_change_hash,
|
||||||
accumulator_root_hash,
|
accumulator_root_hash,
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ["inserted_timestamp"],
|
merge_exclude_columns = ["inserted_timestamp"],
|
||||||
cluster_by = ['block_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(version,tx_hash);",
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','event_index','version','block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ["inserted_timestamp"],
|
|
||||||
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(tx_hash, version, account_address,token_address);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(tx_hash, version, account_address,token_address);",
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
@ -43,9 +41,7 @@ AND modified_timestamp >= (
|
|||||||
{{ this }}
|
{{ this }}
|
||||||
)
|
)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
block_number,
|
block_number,
|
||||||
block_timestamp,
|
block_timestamp,
|
||||||
@ -75,4 +71,4 @@ AND modified_timestamp >= (
|
|||||||
FROM
|
FROM
|
||||||
{{ this }}
|
{{ this }}
|
||||||
)
|
)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
{{ config(
|
|
||||||
materialized = 'incremental',
|
|
||||||
unique_key = ['tx_hash', 'change_index'],
|
|
||||||
incremental_strategy = 'merge',
|
|
||||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ['inserted_timestamp'],
|
|
||||||
cluster_by = ['modified_timestamp::DATE'],
|
|
||||||
tags = ['core'],
|
|
||||||
enabled = false
|
|
||||||
) }}
|
|
||||||
-- depends_on: {{ ref('core__fact_transactions') }}
|
|
||||||
SELECT
|
|
||||||
A.block_number,
|
|
||||||
block_timestamp,
|
|
||||||
tx_hash,
|
|
||||||
version,
|
|
||||||
success,
|
|
||||||
tx_type,
|
|
||||||
payload_function,
|
|
||||||
index AS change_index,
|
|
||||||
DATA :data AS change_data,
|
|
||||||
DATA :type :: STRING AS change_type,
|
|
||||||
DATA :address :: STRING AS address,
|
|
||||||
DATA :handle :: STRING AS handle,
|
|
||||||
DATA :"type" :: STRING AS inner_change_type,
|
|
||||||
SPLIT_PART(
|
|
||||||
inner_change_type,
|
|
||||||
'::',
|
|
||||||
1
|
|
||||||
) :: STRING AS change_address,
|
|
||||||
SPLIT_PART(
|
|
||||||
inner_change_type,
|
|
||||||
'::',
|
|
||||||
2
|
|
||||||
) :: STRING AS change_module,
|
|
||||||
SUBSTRING(inner_change_type, len(change_address) + len(change_module) + 5) AS change_resource,
|
|
||||||
VALUE :key :: STRING AS key,
|
|
||||||
VALUE :value :: STRING AS VALUE,
|
|
||||||
VALUE :state_key_hash :: STRING AS state_key_hash,
|
|
||||||
{{ dbt_utils.generate_surrogate_key(
|
|
||||||
['tx_hash','change_index']
|
|
||||||
) }} AS changes_id,
|
|
||||||
inserted_timestamp,
|
|
||||||
modified_timestamp
|
|
||||||
FROM
|
|
||||||
{{ ref(
|
|
||||||
'core__fact_transactions'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
{% if is_incremental() %}
|
|
||||||
WHERE
|
|
||||||
A.modified_timestamp >= (
|
|
||||||
SELECT
|
|
||||||
DATEADD('minute', -15, MAX(modified_timestamp))
|
|
||||||
FROM
|
|
||||||
{{ this }})
|
|
||||||
{% endif %}
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
{{ config(
|
|
||||||
materialized = 'incremental',
|
|
||||||
unique_key = ['tx_hash','event_index'],
|
|
||||||
incremental_strategy = 'merge',
|
|
||||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ['inserted_timestamp'],
|
|
||||||
cluster_by = ['modified_timestamp::DATE'],
|
|
||||||
tags = ['core'],
|
|
||||||
enabled = false
|
|
||||||
) }}
|
|
||||||
-- depends_on: {{ ref('core__fact_transactions') }}
|
|
||||||
SELECT
|
|
||||||
A.block_number,
|
|
||||||
A.block_timestamp,
|
|
||||||
A.tx_hash,
|
|
||||||
version,
|
|
||||||
success,
|
|
||||||
A.tx_type,
|
|
||||||
A.payload_function,
|
|
||||||
b.index AS event_index,
|
|
||||||
b.value :type :: STRING AS event_type,
|
|
||||||
SPLIT_PART(
|
|
||||||
event_type,
|
|
||||||
'::',
|
|
||||||
1
|
|
||||||
) :: STRING AS event_address,
|
|
||||||
SPLIT_PART(
|
|
||||||
event_type,
|
|
||||||
'::',
|
|
||||||
2
|
|
||||||
) :: STRING AS event_module,
|
|
||||||
SPLIT_PART(
|
|
||||||
event_type,
|
|
||||||
'::',
|
|
||||||
3
|
|
||||||
) :: STRING AS event_resource,
|
|
||||||
b.value :data AS event_data,
|
|
||||||
-- b.value :guid :: STRING AS event_guid, -- extract into account_address + creation_number
|
|
||||||
b.value :guid :account_address :: STRING AS account_address,
|
|
||||||
b.value :guid :creation_number :: bigint AS creation_number,
|
|
||||||
b.value :sequence_number :: bigint AS sequence_number,
|
|
||||||
{{ dbt_utils.generate_surrogate_key(
|
|
||||||
['tx_hash','event_index']
|
|
||||||
) }} AS events_id,
|
|
||||||
inserted_timestamp,
|
|
||||||
modified_timestamp
|
|
||||||
FROM
|
|
||||||
{{ ref(
|
|
||||||
'core__fact_transactions'
|
|
||||||
) }} A,
|
|
||||||
LATERAL FLATTEN (events) b
|
|
||||||
|
|
||||||
{% if is_incremental() %}
|
|
||||||
WHERE
|
|
||||||
modified_timestamp >= (
|
|
||||||
SELECT
|
|
||||||
DATEADD('minute', -15, MAX(modified_timestamp))
|
|
||||||
FROM
|
|
||||||
{{ this }})
|
|
||||||
{% endif %}
|
|
||||||
@ -1,12 +1,11 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','change_index'],
|
unique_key = ['version','change_index'],
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'merge',
|
||||||
cluster_by = ['block_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE'],
|
||||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(store_address);",
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(store_address);",
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
) }}
|
) }}
|
||||||
|
|
||||||
-- depends_on: {{ ref('core__fact_changes') }}
|
-- depends_on: {{ ref('core__fact_changes') }}
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash', 'block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::DATE"],
|
|
||||||
merge_exclude_columns = ['inserted_timestamp'],
|
|
||||||
cluster_by = ['modified_timestamp::DATE'],
|
cluster_by = ['modified_timestamp::DATE'],
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
) }}
|
) }}
|
||||||
@ -11,7 +9,7 @@
|
|||||||
WITH from_transactions AS (
|
WITH from_transactions AS (
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
value :BLOCK_NUMBER :: bigint AS block_number,
|
VALUE :BLOCK_NUMBER :: bigint AS block_number,
|
||||||
TO_TIMESTAMP(
|
TO_TIMESTAMP(
|
||||||
VALUE :BLOCK_TIMESTAMP :: STRING
|
VALUE :BLOCK_TIMESTAMP :: STRING
|
||||||
) AS block_timestamp,
|
) AS block_timestamp,
|
||||||
@ -21,23 +19,23 @@ WITH from_transactions AS (
|
|||||||
DATA,
|
DATA,
|
||||||
inserted_timestamp AS file_last_updated
|
inserted_timestamp AS file_last_updated
|
||||||
FROM
|
FROM
|
||||||
{% if is_incremental() %}
|
|
||||||
{{ ref('bronze__transactions') }}
|
{% if is_incremental() %}
|
||||||
{% else %}
|
{{ ref('bronze__transactions') }}
|
||||||
{{ ref('bronze__transactions_FR') }}
|
{% else %}
|
||||||
|
{{ ref('bronze__transactions_FR') }}
|
||||||
|
{% endif %}
|
||||||
|
WHERE
|
||||||
|
version BETWEEN VALUE :FIRST_VERSION :: bigint
|
||||||
|
AND VALUE :LAST_VERSION :: bigint
|
||||||
|
|
||||||
|
{% if is_incremental() %}
|
||||||
|
AND inserted_timestamp >= (
|
||||||
|
SELECT
|
||||||
|
DATEADD('minute', -5, MAX(modified_timestamp))
|
||||||
|
FROM
|
||||||
|
{{ this }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
WHERE
|
|
||||||
version BETWEEN VALUE :FIRST_VERSION :: bigint
|
|
||||||
AND VALUE :LAST_VERSION :: bigint
|
|
||||||
|
|
||||||
{% if is_incremental() %}
|
|
||||||
AND inserted_timestamp >= (
|
|
||||||
SELECT
|
|
||||||
DATEADD('minute', -5, MAX(modified_timestamp))
|
|
||||||
FROM
|
|
||||||
{{ this }})
|
|
||||||
{% endif %}
|
|
||||||
),
|
),
|
||||||
transformed AS (
|
transformed AS (
|
||||||
SELECT
|
SELECT
|
||||||
@ -70,7 +68,7 @@ transformed AS (
|
|||||||
DATA :id :: STRING AS id,
|
DATA :id :: STRING AS id,
|
||||||
DATA :previous_block_votes_bitvec AS previous_block_votes_bitvec,
|
DATA :previous_block_votes_bitvec AS previous_block_votes_bitvec,
|
||||||
DATA :proposer :: STRING AS proposer,
|
DATA :proposer :: STRING AS proposer,
|
||||||
DATA :round :: INT AS round,
|
DATA :round :: INT AS ROUND,
|
||||||
DATA,
|
DATA,
|
||||||
file_last_updated
|
file_last_updated
|
||||||
FROM
|
FROM
|
||||||
@ -111,6 +109,6 @@ SELECT
|
|||||||
SYSDATE() AS modified_timestamp,
|
SYSDATE() AS modified_timestamp,
|
||||||
'{{ invocation_id }}' AS _invocation_id
|
'{{ invocation_id }}' AS _invocation_id
|
||||||
FROM
|
FROM
|
||||||
transformed qualify(ROW_NUMBER() over (PARTITION BY tx_hash
|
transformed qualify(ROW_NUMBER() over (PARTITION BY version
|
||||||
ORDER BY
|
ORDER BY
|
||||||
file_last_updated DESC)) = 1
|
file_last_updated DESC)) = 1
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','event_index','block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
merge_exclude_columns = ["inserted_timestamp"],
|
|
||||||
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
) }}
|
) }}
|
||||||
|
|||||||
@ -1,16 +1,13 @@
|
|||||||
{{ config(
|
{{ config(
|
||||||
materialized = 'incremental',
|
materialized = 'incremental',
|
||||||
unique_key = ['tx_hash','event_index','block_timestamp::DATE'],
|
unique_key = 'version',
|
||||||
incremental_strategy = 'merge',
|
incremental_strategy = 'delete+insert',
|
||||||
merge_exclude_columns = ["inserted_timestamp"],
|
|
||||||
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
|
||||||
tags = ['core']
|
tags = ['core']
|
||||||
) }}
|
) }}
|
||||||
|
|
||||||
-- depends_on: {{ ref('core__fact_events') }}
|
-- depends_on: {{ ref('core__fact_events') }}
|
||||||
-- depends_on: {{ ref('silver__fungiblestore_owners') }}
|
-- depends_on: {{ ref('silver__fungiblestore_owners') }}
|
||||||
-- depends_on: {{ ref('silver__fungiblestore_metadata') }}
|
-- depends_on: {{ ref('silver__fungiblestore_metadata') }}
|
||||||
|
|
||||||
{% if execute %}
|
{% if execute %}
|
||||||
{% set base_query %}
|
{% set base_query %}
|
||||||
CREATE
|
CREATE
|
||||||
|
|||||||
@ -310,8 +310,7 @@ models:
|
|||||||
tests:
|
tests:
|
||||||
- not_null:
|
- not_null:
|
||||||
tags: ['test_quality']
|
tags: ['test_quality']
|
||||||
- dbt_utils.expression_is_true:
|
- unique:
|
||||||
expression: ">= 0"
|
|
||||||
tags: ['test_quality']
|
tags: ['test_quality']
|
||||||
- name: tx_type
|
- name: tx_type
|
||||||
data_type: VARCHAR
|
data_type: VARCHAR
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user