mirror of
https://github.com/FlipsideCrypto/flow-models.git
synced 2026-02-06 11:26:53 +00:00
* core views * defi schema * bridge test upd * gov schema * nft schema * price schema * move tx count to blocks model * add collection_count_agg to blocks * upd core views to UNION ALL * upd collections cluster_by * upd dim moment metadata to qualify * upd dim moment metadata test * upd core dim contract labels to qualify and silver (cw) to incr * upd str blocks lookback`
53 lines
1.0 KiB
SQL
53 lines
1.0 KiB
SQL
{{ config(
|
|
materialized = 'incremental',
|
|
incremental_strategy = 'delete+insert',
|
|
cluster_by = ['event_contract'],
|
|
unique_key = 'event_contract',
|
|
tags = ['scheduled', 'chainwalkers_scheduled']
|
|
) }}
|
|
|
|
WITH splt AS (
|
|
|
|
SELECT
|
|
event_contract,
|
|
SPLIT(
|
|
event_contract,
|
|
'.'
|
|
) AS ec_s,
|
|
_inserted_timestamp
|
|
FROM
|
|
{{ ref('silver__events') }}
|
|
|
|
{% if is_incremental() %}
|
|
WHERE
|
|
_inserted_timestamp >= (
|
|
SELECT
|
|
MAX(_inserted_timestamp)
|
|
FROM
|
|
{{ this }}
|
|
)
|
|
{% endif %}
|
|
),
|
|
FINAL AS (
|
|
SELECT
|
|
DISTINCT event_contract,
|
|
ec_s [array_size(ec_s)-1] :: STRING AS contract_name,
|
|
CONCAT(
|
|
'0x',
|
|
ec_s [array_size(ec_s)-2] :: STRING
|
|
) AS account_address,
|
|
_inserted_timestamp
|
|
FROM
|
|
splt
|
|
WHERE
|
|
ec_s [0] != 'flow'
|
|
)
|
|
SELECT
|
|
*
|
|
FROM
|
|
FINAL qualify ROW_NUMBER() over (
|
|
PARTITION BY event_contract
|
|
ORDER BY
|
|
_inserted_timestamp DESC
|
|
) = 1
|