optimism-models/models/silver/core/silver__tx_count.sql
drethereum 2c695fc815
An-5333-v2/op-standardization (#312)
* 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
2025-02-12 13:30:50 -07:00

39 lines
804 B
SQL

{{ config(
materialized = 'incremental',
unique_key = "block_number",
merge_exclude_columns = ["inserted_timestamp"],
tags = ['non_realtime']
) }}
WITH base AS (
SELECT
block_number,
MIN(modified_timestamp) AS _inserted_timestamp,
COUNT(*) AS tx_count
FROM
{{ ref('core__fact_transactions') }}
{% if is_incremental() %}
WHERE
modified_timestamp >= (
SELECT
MAX(_inserted_timestamp) _inserted_timestamp
FROM
{{ this }}
)
{% endif %}
GROUP BY
block_number
)
SELECT
*,
{{ dbt_utils.generate_surrogate_key(
['block_number']
) }} AS tx_count_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
base