From 431f3978d4f108029a93a9f122d82f38e400d24f Mon Sep 17 00:00:00 2001 From: alexshchur <60445720+alexshchur@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:08:20 +0000 Subject: [PATCH] fix: add order_index to unique key --- .../_project/paraswap/delta/v1/safe_settle_batch_swap.sql | 2 +- .../dex/models/_projects/paraswap/ethereum/_schema.yml | 3 +++ .../paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/safe_settle_batch_swap.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/safe_settle_batch_swap.sql index a82bc9991c9..fc6c2c23412 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/safe_settle_batch_swap.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/safe_settle_batch_swap.sql @@ -16,7 +16,7 @@ safe_settle_batch_swap_ExpandedOrders AS ( {% endif %} ), safe_settle_batch_swap_parsedOrderItems AS ( SELECT - index, + index as order_index, JSON_ARRAY_GET(parsed_orders, index) AS parsed_order_data, * FROM safe_settle_batch_swap_ExpandedOrders diff --git a/dbt_subprojects/dex/models/_projects/paraswap/ethereum/_schema.yml b/dbt_subprojects/dex/models/_projects/paraswap/ethereum/_schema.yml index dfef6d55012..edab1e52007 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/ethereum/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/paraswap/ethereum/_schema.yml @@ -306,9 +306,12 @@ models: - method - call_tx_hash - call_trace_address + - index columns: - name: method description: "Call Method" + - name: order_index + description: "Index of the Order in Batch (0 if single order swap)" - name: call_trace_address description: "Call Trace Address" - name: call_block_number diff --git a/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql b/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql index 696bd441cb6..12041527a7a 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql @@ -9,7 +9,7 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.call_block_time')], - unique_key = ['method', 'call_tx_hash', 'call_trace_address'], + unique_key = ['method', 'call_tx_hash', 'call_trace_address', 'order_index'], post_hook='{{ expose_spells(blockchains = \'["ethereum"]\', spell_type = "project", spell_name = "paraswap_delta_v1", @@ -24,6 +24,7 @@ with ,{{ delta_safe_settle_batch_swap('ethereum') }} select 'delta_v1_settle_swap_model' as method, + 0 as order_index, call_trace_address, call_block_number, call_block_time, @@ -53,6 +54,7 @@ select union all select 'delta_v1_safe_settle_batch_swap_model' as method, + order_index, call_trace_address, call_block_number, call_block_time,