blitz-market-stats-fix-and-backup-models (#51)

* add update and fix

* ticker fix

* quick fixes

* remove market depth qualify

* update comment

* depth config

* merge strat
This commit is contained in:
Matt Romano 2024-05-17 08:04:51 -07:00 committed by GitHub
parent eb103688e4
commit 94a617da51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
incremental_strategy = 'merge',
full_refresh = false,
unique_key = ['product_id','hour','price'],
cluster_by = ['hour::DATE'],
tags = 'curated'

View File

@ -1,5 +1,6 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'merge',
full_refresh = false,
unique_key = ['ticker_id','hour'],
cluster_by = ['HOUR::DATE'],
@ -36,7 +37,7 @@ market_stats AS (
f.value :quote_currency :: STRING AS quote_currency,
f.value :quote_volume :: FLOAT AS quote_volume,
f.key AS ticker_id,
SYSDATE() AS _inserted_timestamp
SYSDATE() AS inserted_timestamp
FROM
api_pull A,
LATERAL FLATTEN(
@ -51,7 +52,7 @@ trade_snapshot AS (
) AS HOUR,
CONCAT(
symbol,
'_USDC'
'_USDB'
) AS ticker_id,
symbol,
product_id,
@ -68,7 +69,7 @@ trade_snapshot AS (
{{ ref('silver__blitz_perps') }}
p
WHERE
block_timestamp > SYSDATE() - INTERVAL '12 hour'
block_timestamp > '2024-04-16 00:00:00.000' --start of api pulls
GROUP BY
1,
2,
@ -162,13 +163,13 @@ FROM
)
SELECT
*,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
{{ dbt_utils.generate_surrogate_key(
['ticker_id','hour']
) }} AS blitz_market_stats_id,
'{{ invocation_id }}' AS _invocation_id
FROM
FINAL qualify(ROW_NUMBER() over(PARTITION BY ticker_id, HOUR
FINAL
WHERE FUNDING_RATE <> 0 qualify(ROW_NUMBER() over(PARTITION BY ticker_id, HOUR
ORDER BY
_inserted_timestamp DESC)) = 1
_inserted_timestamp DESC NULLS LAST)) = 1