crosschain-models/macros/tests/hour_gaps.sql
drethereum 0634e70350
AN-2917/upgrade-prices (#117)
* coin gecko and cmc prices tables for all blockchains

* all_providers prices draft

* standardized platform column

* asset metadata, priority prices, and core dimensional/fact/ez tables for prices, metadata and contracts

* yml changes

* resolved issues with compiling

* prioritized symbol in prices

* unique address on ez prices

* updates to asset_metadata for efficiency

* asset_metadata updates for blockchain and unique_key

* prioritized coingecko symbol and decimals

* removed test

* removed eth pow and eth classic

* SO on priority prices model

* moved symbol and decimal joins to view layer

* moved dim_contracts join to asset_metadata view

* moved asset_metadata contracts join to view layer

* priority model for ez_asset_metadata and docs

* qualify statements modified
2023-04-06 10:32:05 -06:00

20 lines
451 B
SQL

{% test hour_gaps(
model,
column_name
) %}
WITH gap_times AS (
SELECT t1.{{ column_name }} AS start_time,
MIN(t2.{{ column_name }}) AS end_time
FROM {{ model }} t1
LEFT JOIN {{ model }} t2
ON t2.{{ column_name }} > t1.{{ column_name }}
GROUP BY 1
ORDER BY start_time DESC
)
SELECT *
FROM gap_times
WHERE end_time IS NOT NULL
AND start_time::timestamp + INTERVAL '1 hour' <> end_time::timestamp
{% endtest %}