From 010553a49d00d22bdee52b57541875649db52bfe Mon Sep 17 00:00:00 2001 From: Chuxin Huang Date: Fri, 6 Sep 2024 15:12:45 -0400 Subject: [PATCH] Adding Combined View for Address Gas and Usage; fixing tx hash (#2048) fix tx_hash instead of block_hash Co-authored-by: Carl Cervone <42869436+ccerv1@users.noreply.github.com> --- .../macros/models/first_time_addresses.sql | 2 +- .../users/int_addresses_usage.sql | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 warehouse/dbt/models/intermediate/users/int_addresses_usage.sql diff --git a/warehouse/dbt/macros/models/first_time_addresses.sql b/warehouse/dbt/macros/models/first_time_addresses.sql index 5fdf421b1..6e8816e0b 100644 --- a/warehouse/dbt/macros/models/first_time_addresses.sql +++ b/warehouse/dbt/macros/models/first_time_addresses.sql @@ -22,7 +22,7 @@ from ( ,min(block_timestamp) as first_block_timestamp ,min(block_number) as first_block_number ,min_by(to_address, block_number) as first_tx_to - ,min_by(block_hash, block_number) as first_tx_hash + ,min_by(`hash`, block_number) as first_tx_hash ,min_by(substring(input, 1, 10), block_number) as first_method_id from {{ oso_source(lower_network_name, "transactions") }} where diff --git a/warehouse/dbt/models/intermediate/users/int_addresses_usage.sql b/warehouse/dbt/models/intermediate/users/int_addresses_usage.sql new file mode 100644 index 000000000..a7008d546 --- /dev/null +++ b/warehouse/dbt/models/intermediate/users/int_addresses_usage.sql @@ -0,0 +1,22 @@ +{% set network_names = [ + 'base', + 'frax', + 'metal', + 'mode', + 'optimism', + 'zora' +] %} -- +{% if target.name == 'production' %} +{# This is a temporary measure for now to cut costs on the playground #} +{% set network_names = network_names %} +{% endif %} + +{% for network_name in network_names %} + + select * from {{ ref('stg_%s__addresses_gas_and_usage' % network_name) }} + + {% if not loop.last %} + union all + {% endif %} + +{% endfor %}