From 441e1c91fe3dca1de61435a761f3bb04b904995e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20R=C3=ADos?= Date: Tue, 22 Oct 2024 19:10:27 -0700 Subject: [PATCH] fix: float `overflow` for base traces (#2378) * fix: override `value` field to be of type `bytes` * fix: cast back `value` to `float` on `base` traces * fix: use correct `type` to avoid overflows --- .../blockchain_events/int_base_traces.sql | 17 ++++++++++++++++- .../dbt/models/marts/superchain/4337_traces.sql | 16 ++++++++++++++-- warehouse/oso_dagster/assets/base.py | 6 ++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/warehouse/dbt/models/intermediate/blockchain_events/int_base_traces.sql b/warehouse/dbt/models/intermediate/blockchain_events/int_base_traces.sql index a2014c623..204723cf7 100644 --- a/warehouse/dbt/models/intermediate/blockchain_events/int_base_traces.sql +++ b/warehouse/dbt/models/intermediate/blockchain_events/int_base_traces.sql @@ -11,4 +11,19 @@ incremental_strategy="insert_overwrite" ) }} -{{ filtered_blockchain_events("BASE", "base", "traces") }} + +with base_traces as ( + {{ filtered_blockchain_events("BASE", "base", "traces") }} +), + +transformed_traces as ( + select + *, + CAST(`value` as FLOAT64) as numeric_value + from base_traces +) + +select + * except (`value`, numeric_value), + numeric_value as `value` +from transformed_traces diff --git a/warehouse/dbt/models/marts/superchain/4337_traces.sql b/warehouse/dbt/models/marts/superchain/4337_traces.sql index 51c2555e0..b8b7c3d9c 100644 --- a/warehouse/dbt/models/marts/superchain/4337_traces.sql +++ b/warehouse/dbt/models/marts/superchain/4337_traces.sql @@ -58,7 +58,19 @@ with filtered_traces as ( {{ final_query }} +), + +transformed_traces as ( + select + *, + case + when network = 'BASE' then CAST(`value` as FLOAT64) + else `value` + end as numeric_value + from filtered_traces ) -select * -from filtered_traces +select + * except (`value`, numeric_value), + numeric_value as `value` +from transformed_traces diff --git a/warehouse/oso_dagster/assets/base.py b/warehouse/oso_dagster/assets/base.py index d312272ca..e9c25e903 100644 --- a/warehouse/oso_dagster/assets/base.py +++ b/warehouse/oso_dagster/assets/base.py @@ -1,7 +1,13 @@ from ..factories.goldsky import goldsky_network_assets +from ..factories.goldsky.config import NetworkAssetSourceConfigDict base_network = goldsky_network_assets( network_name="base", destination_dataset_name="superchain", working_destination_dataset_name="oso_raw_sources", + traces_config=NetworkAssetSourceConfigDict( + schema_overrides=[ + {"name": "value", "field_type": "STRING"}, + ] + ), )