blast-models/models/silver/core/silver__tx_count.sql
drethereum 13ba135a6c
AN-5335-v2/blast-standardization (#79)
* new columns ymls and docs

* new column in silver logs

* refs to core fact tables

* ymls and new columns

* minor updates

* columns

* docs

* updates for native transfer

* updates

* deprecation notices

* native transfers table

* core column changes and docs

* full_decoded_log changes

* merge

* misc updates for deprecating columns

* tx and trace status

* misc updates

* remove comments

* remove trace_address from native_transfers

* timestamps for native

* docs

* token transfers

* missing_decoding macro

* l1 fee precise

* removed trace address column from silver native transfers

* deprecation date

* ez decoded_event_logs

* standard pred
2025-02-12 13:59:21 -07:00

39 lines
784 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)
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