optimism-models/models/bronze/bronze__state_hashes.sql
drethereum 6623a042f3
AN-5991/op-migration (#340)
* streamline bronze

* silver models

* gold tables

* docs, gha

* bronze folders

* macros

* make file, packages, project yml, delete tests

* remove silver nft transfers ref

* sources

* macro tests

* update for fsc-evm changes - package, makefile, sources, dbt_project, workflows, docs

* gold tags

* add ethereum models back in

* silver bridge tags

* dex tags

* lending tags

* nft tags

* added back protocols folder and tagged

* temp package

* docs

* docs

* wh

* observability exclusions

* 48

* v51

* 52

* 53

---------

Co-authored-by: sam <sam@flipsidecrypto.com>
2025-05-08 13:54:57 -06:00

43 lines
974 B
SQL

{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "state_block_number",
tags = ['bronze','ethereum']
) }}
SELECT
state_tx_hash,
state_block_number,
state_block_timestamp,
state_batch_index,
state_batch_root,
bedrock_state_batch_index,
bedrock_state_batch_root,
state_batch_size,
state_prev_total_elements,
state_min_block,
state_max_block,
_inserted_timestamp,
{{ dbt_utils.generate_surrogate_key(
['state_block_number']
) }} AS state_hashes_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
{{ source(
'ethereum_silver',
'optimism_state_hashes'
) }}
{% if is_incremental() %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}