-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update nft trades to match dex trades materialization design & ensure…
… incremental / partition design in place (#1396) * add block_date, update config block to partition by block_date and add to unique key, update incremental logic * change materialization to view on top of base incremental tables * clean up incremental logic filters * comment out sudoswap until tokenid array is exploded into rows * uncomment sudoswap in nft schema
- Loading branch information
Showing
9 changed files
with
311 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,45 @@ | ||
{{ config( | ||
alias ='events', | ||
materialized ='incremental', | ||
file_format ='delta', | ||
incremental_strategy='merge', | ||
unique_key='unique_trade_id' | ||
alias ='events' | ||
) | ||
}} | ||
|
||
SELECT blockchain, | ||
project, | ||
version, | ||
block_time, | ||
token_id, | ||
NULL::string as collection, | ||
amount_usd, | ||
token_standard, | ||
trade_type, | ||
number_of_items, | ||
NULL::string as trade_category, | ||
evt_type, | ||
seller, | ||
buyer, | ||
amount_original, | ||
amount_raw, | ||
currency_symbol, | ||
currency_contract, | ||
NULL::string as nft_contract_address, | ||
project_contract_address, | ||
NULL::string as aggregator_name, | ||
NULL::string as aggregator_address, | ||
tx_hash, | ||
block_number, | ||
NULL::string as tx_from, | ||
NULL::string as tx_to, | ||
platform_fee_amount_raw, | ||
platform_fee_amount, | ||
platform_fee_amount_usd, | ||
platform_fee_percentage, | ||
royalty_fee_amount_raw, | ||
royalty_fee_amount, | ||
royalty_fee_amount_usd, | ||
royalty_fee_percentage, | ||
NULL::string as royalty_fee_receive_address, | ||
royalty_fee_currency_symbol, | ||
unique_trade_id | ||
FROM {{ ref('magiceden_solana_events') }} | ||
|
||
{% if is_incremental() %} | ||
-- this filter will only be applied on an incremental run | ||
WHERE block_time >= (select max(block_time) from {{ this }}) | ||
{% endif %} | ||
SELECT | ||
blockchain, | ||
project, | ||
version, | ||
block_date, | ||
block_time, | ||
token_id, | ||
NULL::string as collection, | ||
amount_usd, | ||
token_standard, | ||
trade_type, | ||
number_of_items, | ||
NULL::string as trade_category, | ||
evt_type, | ||
seller, | ||
buyer, | ||
amount_original, | ||
amount_raw, | ||
currency_symbol, | ||
currency_contract, | ||
NULL::string as nft_contract_address, | ||
project_contract_address, | ||
NULL::string as aggregator_name, | ||
NULL::string as aggregator_address, | ||
tx_hash, | ||
block_number, | ||
NULL::string as tx_from, | ||
NULL::string as tx_to, | ||
platform_fee_amount_raw, | ||
platform_fee_amount, | ||
platform_fee_amount_usd, | ||
platform_fee_percentage, | ||
royalty_fee_amount_raw, | ||
royalty_fee_amount, | ||
royalty_fee_amount_usd, | ||
royalty_fee_percentage, | ||
NULL::string as royalty_fee_receive_address, | ||
royalty_fee_currency_symbol, | ||
unique_trade_id | ||
FROM {{ ref('magiceden_solana_events') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 85 additions & 91 deletions
176
spellbook/models/opensea/ethereum/opensea_ethereum_events.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,88 @@ | ||
{{ config( | ||
alias ='events', | ||
materialized ='incremental', | ||
file_format ='delta', | ||
incremental_strategy='merge', | ||
unique_key='unique_trade_id' | ||
) | ||
alias ='events' | ||
) | ||
}} | ||
|
||
SELECT blockchain, | ||
project, | ||
version, | ||
block_time, | ||
token_id, | ||
collection, | ||
amount_usd, | ||
token_standard, | ||
trade_type, | ||
number_of_items, | ||
trade_category, | ||
evt_type, | ||
seller, | ||
buyer, | ||
amount_original, | ||
amount_raw, | ||
currency_symbol, | ||
currency_contract, | ||
nft_contract_address, | ||
project_contract_address, | ||
aggregator_name, | ||
aggregator_address, | ||
block_number, | ||
tx_hash, | ||
tx_from, | ||
tx_to, | ||
platform_fee_amount_raw, | ||
platform_fee_amount, | ||
platform_fee_amount_usd, | ||
platform_fee_percentage, | ||
royalty_fee_amount_raw, | ||
royalty_fee_amount, | ||
royalty_fee_amount_usd, | ||
royalty_fee_percentage, | ||
royalty_fee_receive_address, | ||
royalty_fee_currency_symbol, | ||
unique_trade_id | ||
FROM ({{ ref('opensea_v1_ethereum_events') }}) | ||
{% if is_incremental() %} | ||
-- this filter will only be applied on an incremental run | ||
WHERE block_time > now() - interval 2 days | ||
{% endif %} | ||
UNION | ||
SELECT blockchain, | ||
'opensea' as project, | ||
'v3' as version, | ||
block_time, | ||
token_id, | ||
collection, | ||
amount_usd, | ||
token_standard, | ||
trade_type, | ||
number_of_items, | ||
trade_category, | ||
evt_type, | ||
seller, | ||
buyer, | ||
amount_original, | ||
amount_raw, | ||
currency_symbol, | ||
currency_contract, | ||
nft_contract_address, | ||
project_contract_address, | ||
aggregator_name, | ||
aggregator_address, | ||
block_number, | ||
tx_hash, | ||
tx_from, | ||
tx_to, | ||
platform_fee_amount_raw, | ||
platform_fee_amount, | ||
platform_fee_amount_usd, | ||
platform_fee_percentage, | ||
royalty_fee_amount_raw, | ||
royalty_fee_amount, | ||
royalty_fee_amount_usd, | ||
royalty_fee_percentage, | ||
royalty_fee_receive_address, | ||
royalty_fee_currency_symbol, | ||
unique_trade_id | ||
FROM ({{ ref('opensea_v3_ethereum_events') }}) | ||
{% if is_incremental() %} | ||
-- this filter will only be applied on an incremental run | ||
WHERE block_time > now() - interval 2 days | ||
{% endif %} | ||
SELECT * | ||
FROM | ||
( | ||
SELECT | ||
blockchain, | ||
project, | ||
version, | ||
block_time, | ||
token_id, | ||
collection, | ||
amount_usd, | ||
token_standard, | ||
trade_type, | ||
number_of_items, | ||
trade_category, | ||
evt_type, | ||
seller, | ||
buyer, | ||
amount_original, | ||
amount_raw, | ||
currency_symbol, | ||
currency_contract, | ||
nft_contract_address, | ||
project_contract_address, | ||
aggregator_name, | ||
aggregator_address, | ||
tx_hash, | ||
block_number, | ||
tx_from, | ||
tx_to, | ||
platform_fee_amount_raw, | ||
platform_fee_amount, | ||
platform_fee_amount_usd, | ||
platform_fee_percentage, | ||
royalty_fee_amount_raw, | ||
royalty_fee_amount, | ||
royalty_fee_amount_usd, | ||
royalty_fee_percentage, | ||
royalty_fee_receive_address, | ||
royalty_fee_currency_symbol, | ||
unique_trade_id | ||
FROM ({{ ref('opensea_v1_ethereum_events') }}) | ||
UNION | ||
SELECT | ||
blockchain, | ||
'opensea' as project, | ||
'v3' as version, | ||
block_time, | ||
token_id, | ||
collection, | ||
amount_usd, | ||
token_standard, | ||
trade_type, | ||
number_of_items, | ||
trade_category, | ||
evt_type, | ||
seller, | ||
buyer, | ||
amount_original, | ||
amount_raw, | ||
currency_symbol, | ||
currency_contract, | ||
nft_contract_address, | ||
project_contract_address, | ||
aggregator_name, | ||
aggregator_address, | ||
tx_hash, | ||
block_number, | ||
tx_from, | ||
tx_to, | ||
platform_fee_amount_raw, | ||
platform_fee_amount, | ||
platform_fee_amount_usd, | ||
platform_fee_percentage, | ||
royalty_fee_amount_raw, | ||
royalty_fee_amount, | ||
royalty_fee_amount_usd, | ||
royalty_fee_percentage, | ||
royalty_fee_receive_address, | ||
royalty_fee_currency_symbol, | ||
unique_trade_id | ||
FROM ({{ ref('opensea_v3_ethereum_events') }}) | ||
) |
Oops, something went wrong.