This commit is contained in:
WHYTEWYLL 2023-12-14 19:38:36 +01:00
parent 74c4ede02e
commit 108ab61597
3 changed files with 28 additions and 26 deletions

View File

@ -60,4 +60,4 @@ FROM
PARTITION BY event_contract
ORDER BY
_inserted_timestamp DESC
) = 1
) = 1

View File

@ -108,4 +108,4 @@ FROM
PARTITION BY dim_moment_metadata_id
ORDER BY
_inserted_timestamp DESC
) = 1
) = 1

View File

@ -33,7 +33,7 @@ prices_swaps_cw AS (
NULL AS prices_swaps_id,
NULL AS inserted_timestamp,
NULL AS modified_timestamp
FROM
FROM
{{ ref('silver__prices_swaps') }}
),
prices_swaps_s AS (
@ -100,31 +100,33 @@ viewnion AS (
LEFT JOIN token_labels l USING (token_contract)
)
SELECT
TIMESTAMP,
token,
symbol,
token_contract,
price_usd,
source,
tx_id,
COALESCE (
prices_swaps_id,
{{ dbt_utils.generate_surrogate_key(['TIMESTAMP','TOKEN', 'TOKEN_CONTRACT', 'SOURCE']) }}
) AS price_act_prices,
COALESCE (
inserted_timestamp,
TIMESTAMP
) AS inserted_timestamp,
COALESCE (
modified_timestamp,
TIMESTAMP
) AS modified_timestamp
TIMESTAMP,
token,
symbol,
token_contract,
price_usd,
source,
tx_id,
COALESCE (
prices_swaps_id,
{{ dbt_utils.generate_surrogate_key(['TIMESTAMP','TOKEN', 'TOKEN_CONTRACT', 'SOURCE']) }}
) AS price_act_prices,
COALESCE (
inserted_timestamp,
TIMESTAMP
) AS inserted_timestamp,
COALESCE (
modified_timestamp,
TIMESTAMP
) AS modified_timestamp
FROM
viewnion
WHERE
TIMESTAMP IS NOT NULL
qualify ROW_NUMBER() over (
PARTITION BY TIMESTAMP, TOKEN, TOKEN_CONTRACT, SOURCE
TIMESTAMP IS NOT NULL qualify ROW_NUMBER() over (
PARTITION BY TIMESTAMP,
token,
token_contract,
source
ORDER BY
_inserted_timestamp DESC
) = 1
) = 1