Skip to content

Commit afcf498

Browse files
authored
hotfix(sqlmesh): cast to double before multiplication (#4958)
* hotfix(sqlmesh): cast to double before multiplication * fix(sqlmesh): cast to double at staging * fix: include aliases * fix: add tlt field back * revert transactions model * fully revert * fix: apply doubles only to int models
1 parent 8dbce1e commit afcf498

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

warehouse/oso_sqlmesh/models/intermediate/events/blockchain/superchain/int_events__superchain_internal_transactions.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ SELECT
3939
@oso_entity_id(chain, '', to_address_trace) AS to_artifact_id,
4040
'' AS to_artifact_namespace,
4141
to_address_trace AS to_artifact_name,
42-
CAST(gas_used_tx * gas_price_tx AS DOUBLE) AS l2_gas_fee,
43-
COALESCE(gas_used_trace, 0) AS gas_used_trace,
44-
(to_address_trace=to_address_tx) AS is_top_level_transaction,
42+
gas_used_tx::DOUBLE * gas_price_tx::DOUBLE AS l2_gas_fee,
43+
COALESCE(gas_used_trace, 0)::DOUBLE AS gas_used_trace,
4544
COALESCE(gas_used_trace, 0) / NULLIF(
4645
SUM(COALESCE(gas_used_trace, 0)) OVER (
4746
PARTITION BY chain, transaction_hash
4847
), 0
49-
) AS share_of_transaction_gas
48+
) AS share_of_transaction_gas,
49+
(to_address_trace=to_address_tx) AS is_top_level_transaction
5050
FROM oso.int_superchain_traces_txs_joined
5151
WHERE block_timestamp BETWEEN @start_dt AND @end_dt

warehouse/oso_sqlmesh/models/intermediate/events/blockchain/superchain/int_events__superchain_transactions.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ SELECT
4242
'' AS to_artifact_namespace,
4343
to_address AS to_artifact_name,
4444
transaction_type,
45-
CAST(receipt_effective_gas_price * receipt_gas_used AS DOUBLE) AS l2_gas_fee,
46-
CAST(receipt_l1_fee AS DOUBLE) AS l1_gas_fee,
45+
receipt_effective_gas_price::DOUBLE * receipt_gas_used::DOUBLE AS l2_gas_fee,
46+
receipt_l1_fee::DOUBLE AS l1_gas_fee,
4747
transaction_hash
4848
FROM oso.stg_superchain__transactions
4949
WHERE

0 commit comments

Comments
 (0)