diff --git a/models/gold/stats/gold_stats.yml b/models/gold/stats/gold_stats.yml new file mode 100644 index 0000000..779f6e7 --- /dev/null +++ b/models/gold/stats/gold_stats.yml @@ -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") }}' \ No newline at end of file diff --git a/models/gold/stats/stats__ez_core_metrics_hourly.sql b/models/gold/stats/stats__ez_core_metrics_hourly.sql new file mode 100644 index 0000000..5ee7a47 --- /dev/null +++ b/models/gold/stats/stats__ez_core_metrics_hourly.sql @@ -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 \ No newline at end of file