added stats gold, still need incrementality

This commit is contained in:
Mike Stepanovic 2025-03-18 15:13:14 -06:00
parent 6aded6d497
commit a58df58f94
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,37 @@
version: 2
models:
- name: stats__ez_core_metrics_hourly
description: '{{ doc("ez_core_metrics_hourly_table_doc") }}'
columns:
- name: BLOCK_TIMESTAMP_HOUR
description: '{{ doc("block_timestamp_hour") }}'
- name: BLOCK_NUMBER_MIN
description: '{{ doc("block_number_min") }}'
- name: BLOCK_NUMBER_MAX
description: '{{ doc("block_number_max") }}'
- name: BLOCK_COUNT
description: '{{ doc("block_count") }}'
- name: TRANSACTION_COUNT
description: '{{ doc("transaction_count") }}'
- name: TRANSACTION_COUNT_SUCCESS
description: '{{ doc("transaction_count_success") }}'
- name: TRANSACTION_COUNT_FAILED
description: '{{ doc("transaction_count_failed") }}'
- name: UNIQUE_SENDER_COUNT
description: '{{ doc("unique_sender_count") }}'
- name: UNIQUE_PAYLOAD_FUNCTION_COUNT
description: '{{ doc("unique_payload_function_count") }}'
- name: TOTAL_FEES_NATIVE
description: '{{ doc("total_fees_native") }}'
- name: TOTAL_FEES_USD
description: '{{ doc("total_fees_usd") }}'
tests:
- not_null:
tags: ['test_quality']
- name: EZ_CORE_METRICS_HOURLY_ID
description: '{{ doc("pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -0,0 +1,40 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_timestamp_hour",
cluster_by = ['block_timestamp_hour::DATE'],
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STATS, METRICS, CORE, HOURLY',
} } },
tags = ['noncore']
) }}
SELECT
block_timestamp_hour,
block_number_min,
block_number_max,
block_count,
transaction_count,
transaction_count_success,
transaction_count_failed,
unique_sender_count,
unique_payload_function_count,
total_fees AS total_fees_native,
ROUND(
(total_fees / pow(
10,
8
)) * p.price,
2
) AS total_fees_usd,
core_metrics_hourly_id AS ez_core_metrics_hourly_id,
s.inserted_timestamp AS inserted_timestamp,
s.modified_timestamp AS modified_timestamp
FROM
{{ ref('silver_stats__core_metrics_hourly') }}
s
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
p
ON s.block_timestamp_hour = p.hour
WHERE
p.is_native
AND p.price IS NOT NULL