mirror of
https://github.com/FlipsideCrypto/movement-models.git
synced 2026-02-06 16:01:57 +00:00
added incremental logic, switched silver to view
This commit is contained in:
parent
a58df58f94
commit
a748a0917e
@ -37,4 +37,9 @@ FROM
|
||||
ON s.block_timestamp_hour = p.hour
|
||||
WHERE
|
||||
p.is_native
|
||||
AND p.price IS NOT NULL
|
||||
{% if is_incremental() %}
|
||||
AND s.block_timestamp_hour >= (
|
||||
SELECT
|
||||
MAX(block_timestamp_hour)
|
||||
FROM {{ this }})
|
||||
{% endif %}
|
||||
@ -1,29 +1,12 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_timestamp_hour",
|
||||
cluster_by = ['block_timestamp_hour::DATE'],
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STATS, METRICS, CORE, HOURLY',
|
||||
} } },
|
||||
tags = ['noncore']
|
||||
) }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
{% set min_block_timestamp_hour_query %}
|
||||
SELECT
|
||||
MIN(DATE_TRUNC('hour', block_timestamp)) as block_timestamp_hour
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
WHERE
|
||||
inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endset %}
|
||||
|
||||
{% set min_block_timestamp_hour = run_query(min_block_timestamp_hour_query).columns[0].values()[0] %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
DATE_TRUNC(
|
||||
'hour',
|
||||
@ -67,12 +50,5 @@ WHERE
|
||||
'hour',
|
||||
CURRENT_TIMESTAMP
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) >= '{{ min_block_timestamp_hour }}'
|
||||
{% endif %}
|
||||
GROUP BY
|
||||
1
|
||||
Loading…
Reference in New Issue
Block a user