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`
36 lines
894 B
SQL
36 lines
894 B
SQL
-- depends_on: {{ ref('bronze__streamline_collections') }}
|
|
{{ config(
|
|
materialized = 'incremental',
|
|
unique_key = "collection_id",
|
|
cluster_by = ['_inserted_timestamp :: DATE', 'block_number'],
|
|
tags = ['streamline_load', 'core']
|
|
) }}
|
|
|
|
SELECT
|
|
block_number,
|
|
DATA: id :: STRING AS collection_id,
|
|
ARRAY_SIZE(
|
|
DATA :transaction_ids :: ARRAY
|
|
) AS tx_count,
|
|
DATA: transaction_ids :: ARRAY AS transaction_ids,
|
|
_partition_by_block_id,
|
|
_inserted_timestamp
|
|
FROM
|
|
|
|
{% if is_incremental() %}
|
|
{{ ref('bronze__streamline_collections') }}
|
|
WHERE
|
|
_inserted_timestamp >= (
|
|
SELECT
|
|
MAX(_inserted_timestamp) _inserted_timestamp
|
|
FROM
|
|
{{ this }}
|
|
)
|
|
{% else %}
|
|
{{ ref('bronze__streamline_fr_collections') }}
|
|
{% endif %}
|
|
|
|
qualify(ROW_NUMBER() over (PARTITION BY collection_id
|
|
ORDER BY
|
|
_inserted_timestamp DESC)) = 1
|