mirror of
https://github.com/FlipsideCrypto/aleo-models.git
synced 2026-02-06 11:06:46 +00:00
refactored fact_transfers
This commit is contained in:
parent
8382c92540
commit
dea06f1ad1
@ -9,7 +9,76 @@
|
||||
tags = ['core','full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
WITH native_transfers AS (
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
tx_succeeded,
|
||||
transition_id,
|
||||
index,
|
||||
transfer_type,
|
||||
sender,
|
||||
receiver,
|
||||
amount,
|
||||
is_native,
|
||||
token_id
|
||||
FROM
|
||||
{{ ref('silver__native_transfers') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= DATEADD(
|
||||
'minute',
|
||||
-5,(
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
nonnative_transfers AS (
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
tx_succeeded,
|
||||
transition_id,
|
||||
index,
|
||||
transfer_type,
|
||||
sender,
|
||||
receiver,
|
||||
amount,
|
||||
is_native,
|
||||
token_id
|
||||
FROM
|
||||
{{ ref('silver__nonnative_transfers') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= DATEADD(
|
||||
'minute',
|
||||
-5,(
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
all_transfers AS (
|
||||
SELECT * FROM native_transfers
|
||||
UNION ALL
|
||||
SELECT * FROM nonnative_transfers
|
||||
)
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
@ -28,59 +97,5 @@ SELECT
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
{{ ref('silver__native_transfers') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= DATEADD(
|
||||
'minute',
|
||||
-5,(
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
tx_succeeded,
|
||||
transition_id,
|
||||
index,
|
||||
transfer_type,
|
||||
sender,
|
||||
receiver,
|
||||
amount,
|
||||
is_native,
|
||||
token_id,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_id','transition_id','transfer_type']
|
||||
) }} AS fact_transfers_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
{{ ref('silver__nonnative_transfers') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= DATEADD(
|
||||
'minute',
|
||||
-5,(
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
)
|
||||
{% endif %}
|
||||
FROM
|
||||
all_transfers
|
||||
Loading…
Reference in New Issue
Block a user