mirror of
https://github.com/FlipsideCrypto/sei-models.git
synced 2026-02-06 15:06:44 +00:00
stats inc logic
This commit is contained in:
parent
c19b694603
commit
f178303863
@ -5,7 +5,26 @@
|
||||
cluster_by = ['block_timestamp_hour::DATE'],
|
||||
tags = ['noncore']
|
||||
) }}
|
||||
/* run incremental timestamp value first then use it as a static value */
|
||||
{% if execute %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
{% set query %}
|
||||
|
||||
SELECT
|
||||
MIN(DATE_TRUNC('hour', block_timestamp)) block_timestamp_hour
|
||||
FROM
|
||||
{{ ref('silver__blocks') }}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
) {% endset %}
|
||||
{% set min_block_timestamp_hour = run_query(query).columns [0].values() [0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
SELECT
|
||||
DATE_TRUNC(
|
||||
'hour',
|
||||
@ -31,13 +50,8 @@ WHERE
|
||||
{% if is_incremental() %}
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
_inserted_timestamp
|
||||
) >= (
|
||||
SELECT
|
||||
MAX(DATE_TRUNC('hour', _inserted_timestamp)) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
block_timestamp
|
||||
) >= '{{ min_block_timestamp_hour }}'
|
||||
{% endif %}
|
||||
GROUP BY
|
||||
1
|
||||
|
||||
@ -5,7 +5,26 @@
|
||||
cluster_by = ['block_timestamp_hour::DATE'],
|
||||
tags = ['noncore']
|
||||
) }}
|
||||
/* run incremental timestamp value first then use it as a static value */
|
||||
{% if execute %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
{% set query %}
|
||||
|
||||
SELECT
|
||||
MIN(DATE_TRUNC('hour', block_timestamp)) block_timestamp_hour
|
||||
FROM
|
||||
{{ ref('silver__transactions_final') }}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
) {% endset %}
|
||||
{% set min_block_timestamp_hour = run_query(query).columns [0].values() [0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
SELECT
|
||||
DATE_TRUNC(
|
||||
'hour',
|
||||
@ -58,13 +77,8 @@ WHERE
|
||||
{% if is_incremental() %}
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
_inserted_timestamp
|
||||
) >= (
|
||||
SELECT
|
||||
MAX(DATE_TRUNC('hour', _inserted_timestamp)) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
block_timestamp
|
||||
) >= '{{ min_block_timestamp_hour }}'
|
||||
{% endif %}
|
||||
GROUP BY
|
||||
1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user