upgrades for coinstore deprecations

This commit is contained in:
Eric Laurello 2025-08-04 17:02:29 -04:00
parent fc433de7ca
commit 3225d39260
16 changed files with 230 additions and 14 deletions

View File

@ -18,5 +18,23 @@ SELECT
modified_timestamp
FROM
{{ ref(
'silver__transfers_native'
'silver__transfers_native_fungible'
) }}
UNION ALL
SELECT
block_number,
block_timestamp,
tx_hash,
version,
success,
from_address,
to_address,
amount,
token_address,
transfers_native_id AS ez_native_transfers_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref(
'silver__transfers_native_vw'
) }}

View File

@ -26,7 +26,7 @@ SELECT
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
FROM
{{ ref('silver__transfers') }}
{{ ref('silver__transfers_vw') }}
WHERE
amount <> 0

View File

@ -4,7 +4,8 @@
incremental_strategy = 'merge',
merge_exclude_columns = ["inserted_timestamp"],
cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE'],
tags = ['core','full_test']
tags = ['core','full_test'],
enabled = false
) }}
WITH events AS (

View File

@ -5,7 +5,8 @@
merge_exclude_columns = ["inserted_timestamp"],
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(tx_hash, version, from_address, to_address);",
tags = ['core','full_test']
tags = ['core','full_test'],
enabled = false
) }}
WITH xfer AS (
@ -106,4 +107,4 @@ WHERE
AND (
wth.event_index + 1 = dep.event_index
OR reg.event_index + 1 = dep.event_index
)
)

View File

@ -0,0 +1,78 @@
{{ config(
materialized = 'incremental',
unique_key = ['tx_hash','_transfer_key','block_timestamp::DATE'],
incremental_strategy = 'merge',
merge_exclude_columns = ["inserted_timestamp"],
cluster_by = ['block_timestamp::DATE'],
tags = ['core','full_test']
) }}
{# post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(tx_hash, version, from_address, to_address);", #}
WITH xfer AS (
SELECT
block_number,
block_timestamp,
tx_hash,
version,
success,
event_index,
transfer_event,
owner_address account_address,
amount,
metadata_address AS token_address
FROM
{{ ref('silver__transfers_fungible') }}
WHERE
amount > 0
AND metadata_address = '0xa'
{% if is_incremental() %}
AND modified_timestamp >= (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
),
wth AS (
SELECT
*
FROM
xfer
WHERE
transfer_event = 'WithdrawEvent'
),
dep AS (
SELECT
*
FROM
xfer
WHERE
transfer_event = 'DepositEvent'
)
SELECT
wth.block_number,
wth.block_timestamp,
wth.tx_hash,
wth.version,
wth.success,
wth.account_address AS from_address,
dep.account_address AS to_address,
wth.amount,
wth.token_address,
wth.event_index || ':' || dep.event_index AS _transfer_key,
{{ dbt_utils.generate_surrogate_key(
['wth.tx_hash','wth.event_index','dep.event_index']
) }} AS transfers_native_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
wth
JOIN dep
ON wth.tx_hash = dep.tx_hash
AND wth.amount = dep.amount
AND wth.event_index + 1 = dep.event_index
WHERE
wth.account_address <> dep.account_address

View File

@ -0,0 +1,25 @@
{{ config(
materialized = 'view'
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
version,
success,
from_address,
to_address,
amount,
token_address,
_transfer_key,
transfers_native_id,
inserted_timestamp,
modified_timestamp,
_inserted_timestamp,
_invocation_id
FROM
{{ source(
'silver',
'transfers_native'
) }}

View File

@ -0,0 +1,27 @@
{{ config(
materialized = 'view'
) }}
SELECT
block_number,
block_timestamp,
tx_hash,
version,
success,
event_index,
creation_number,
transfer_event,
account_address,
amount,
token_inoken_address,
transfers_id,
inserted_timestamp,
modified_timestamp,
_inserted_timestamp,
_invocation_id
FROM
{{ source(
'silver',
'transfers'
) }}
e

View File

@ -1,6 +1,7 @@
{{ config(
materialized = 'view',
tags = ['full_test']
tags = ['full_test'],
enabled = false
) }}
SELECT

View File

@ -1,6 +1,7 @@
{{ config (
materialized = 'view',
tags = ['recent_test']
tags = ['recent_test'],
enabled = false
) }}
WITH last_3_days AS (

View File

@ -1,6 +1,7 @@
{{ config(
materialized = 'view',
tags = ['full_test']
tags = ['full_test'],
enabled = false
) }}
SELECT

View File

@ -1,6 +1,7 @@
{{ config (
materialized = 'view',
tags = ['recent_test']
tags = ['recent_test'],
enabled = false
) }}
WITH last_3_days AS (

View File

@ -4,7 +4,7 @@
incremental_strategy = 'merge',
merge_exclude_columns = ["inserted_timestamp"],
cluster_by = ['modified_timestamp::DATE'],
tags = ['noncore']
tags = ['noncore_retired']
) }}
WITH tx AS (
@ -56,7 +56,7 @@ xfers AS (
token_address,
transfer_event
FROM
{{ ref('silver__transfers') }}
{{ ref('silver__transfers_vw') }}
WHERE
success
AND block_timestamp :: DATE <= '2023-04-05'

View File

@ -46,10 +46,28 @@ xfers AS (
event_index,
token_address
FROM
{{ ref('silver__transfers') }}
{{ ref('silver__transfers_vw') }}
WHERE
success
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp)
FROM
{{ this }}
)
{% endif %}
UNION ALL
SELECT
tx_hash,
event_index,
metadata_address AS token_address
FROM
{{ ref('silver__transfers_fungible') }}
WHERE
success
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT

View File

@ -77,10 +77,29 @@ xfers AS (
transfer_event,
token_address
FROM
{{ ref('silver__transfers') }}
{{ ref('silver__transfers_vw') }}
WHERE
success
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp)
FROM
{{ this }}
)
{% endif %}
UNION ALL
SELECT
tx_hash,
owner_address AS account_address,
transfer_event,
metadata_address AS token_address
FROM
{{ ref('silver__transfers_fungible') }}
WHERE
success
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT

View File

@ -51,10 +51,30 @@ xfers AS (
event_index,
transfer_event
FROM
{{ ref('silver__transfers') }}
{{ ref('silver__transfers_vw') }}
WHERE
success
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp)
FROM
{{ this }}
)
{% endif %}
UNION ALL
SELECT
tx_hash,
owner_address AS account_address,
metadata_address AS token_address,
event_index,
transfer_event
FROM
{{ ref('silver__transfers_fungible') }}
WHERE
success
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT

View File

@ -25,6 +25,11 @@ sources:
schema: bronze
tables:
- name: lq_blocks_txs
- name: silver
schema: silver
tables:
- name: transfers
- name: transfers_native
- name: github_actions
database: aptos
schema: github_actions