mirror of
https://github.com/FlipsideCrypto/optimism-models.git
synced 2026-02-06 18:01:47 +00:00
* new columns, deprecation notices, docs * docs and ymls * new column in silver logs * spacing * spacing * new decoded logs columns, updates for new core columns * updates for column changes * nft updates * minor updates * comments * docs * updates for native transfers * update for identifier * updates for identifier * deprecation notices updated * table notices * native transfers * core column changes and docs * misc updates * typo * ref * removed trace_address from native_transfers * misc updates * timestamps for native * missing changes * misc updates * nft updates * missing_decoding macro * l1 fee precise docs * removed trace address column from silver native transfers * deprecation date * ez_decoded_event_logs * standard pred * dbt_mega
45 lines
1.3 KiB
SQL
45 lines
1.3 KiB
SQL
{{ config (
|
|
materialized = "incremental",
|
|
unique_key = "created_contract_address",
|
|
merge_exclude_columns = ["inserted_timestamp"],
|
|
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(block_timestamp, tx_hash, created_contract_address, creator_address), SUBSTRING(created_contract_address, creator_address)",
|
|
tags = ['non_realtime']
|
|
) }}
|
|
|
|
SELECT
|
|
block_number,
|
|
block_timestamp,
|
|
tx_hash,
|
|
to_address AS created_contract_address,
|
|
from_address AS creator_address,
|
|
input AS created_contract_input,
|
|
modified_timestamp AS _inserted_timestamp,
|
|
{{ dbt_utils.generate_surrogate_key(
|
|
['to_address']
|
|
) }} AS created_contracts_id,
|
|
SYSDATE() AS inserted_timestamp,
|
|
SYSDATE() AS modified_timestamp,
|
|
'{{ invocation_id }}' AS _invocation_id
|
|
FROM
|
|
{{ ref('core__fact_traces') }}
|
|
WHERE
|
|
TYPE ILIKE 'create%'
|
|
AND to_address IS NOT NULL
|
|
AND input IS NOT NULL
|
|
AND input != '0x'
|
|
AND tx_succeeded
|
|
AND trace_succeeded
|
|
|
|
{% if is_incremental() %}
|
|
AND _inserted_timestamp >= (
|
|
SELECT
|
|
MAX(_inserted_timestamp) - INTERVAL '24 hours'
|
|
FROM
|
|
{{ this }}
|
|
)
|
|
{% endif %}
|
|
|
|
qualify(ROW_NUMBER() over(PARTITION BY created_contract_address
|
|
ORDER BY
|
|
_inserted_timestamp DESC)) = 1
|