movement-models/models/gold/price/price__dim_asset_metadata.sql
2025-03-18 15:16:19 -06:00

33 lines
786 B
SQL

{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'dim_asset_metadata_id',
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(token_address, asset_id, symbol, name)",
tags = ['noncore']
) }}
SELECT
token_address,
asset_id,
symbol,
NAME,
platform AS blockchain,
platform_id AS blockchain_id,
provider,
inserted_timestamp,
modified_timestamp,
complete_provider_asset_metadata_id AS dim_asset_metadata_id
FROM
{{ ref('silver__complete_provider_asset_metadata') }}
{% if is_incremental() %}
WHERE
modified_timestamp >= (
SELECT
MAX(
modified_timestamp
)
FROM
{{ this }}
)
{% endif %}