solana-models/models/gold/nft/nft__fact_nft_mints.sql
desmond-hui 034e88e344
An 3943/get compressed nft addresses (#439)
* external funcs (wip)

* call compressed nft mint parser with external func

* ignore bronze_api models

* move to match standard location

* fix missing mints due to inconsistent ordering

* add a tag to bronze_api model, exclude accordingly

* update silver table to use new bronze api data

* wip

* handle non-mint events and multi mints per tx_id

* add regression test
2024-01-15 07:46:46 -08:00

62 lines
1.3 KiB
SQL

{{ config(
materialized = 'view',
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'NFT' }}},
tags = ['scheduled_non_core']
) }}
SELECT
block_timestamp,
block_id,
initialization_tx_id AS tx_id,
succeeded,
program_id,
purchaser,
mint_price,
mint_currency,
mint,
FALSE AS is_compressed,
COALESCE (
nft_mints_id,
{{ dbt_utils.generate_surrogate_key(
['tx_id', 'mint', 'purchaser', 'mint_currency']
) }}
) AS fact_nft_mints_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp
FROM
{{ ref('silver__nft_mints') }}
UNION ALL
SELECT
block_timestamp,
block_id,
tx_id,
succeeded,
program_id,
purchaser,
mint_price,
mint_currency,
mint,
TRUE AS is_compressed,
COALESCE (
nft_compressed_mints_id,
{{ dbt_utils.generate_surrogate_key(
['tx_id','mint']
) }}
) AS fact_nft_mints_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp
FROM
{{ ref('silver__nft_compressed_mints') }}