Skip to content

Commit

Permalink
fix (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinFlipside authored May 31, 2024
1 parent c6f4133 commit 279b826
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions models/silver/core/silver__decoded_logs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -175,35 +175,36 @@ missing_data AS (
t.is_pending
AND l.block_timestamp IS NOT NULL
)
{% endif %}
SELECT
tx_hash,
block_number,
event_index,
event_name,
contract_address,
decoded_data,
transformed,
_log_id,
_inserted_timestamp,
decoded_flat,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
topics,
DATA,
event_removed,
tx_status,
is_pending,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }} AS decoded_logs_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
new_records
{% endif %},
complete_data AS (
SELECT
tx_hash,
block_number,
event_index,
event_name,
contract_address,
decoded_data,
transformed,
_log_id,
_inserted_timestamp,
decoded_flat,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
topics,
DATA,
event_removed,
tx_status,
is_pending,
{{ dbt_utils.generate_surrogate_key(
['tx_hash', 'event_index']
) }} AS decoded_logs_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
new_records

{% if is_incremental() %}
UNION
Expand Down Expand Up @@ -236,7 +237,10 @@ SELECT
FROM
missing_data
{% endif %}

qualify(ROW_NUMBER() over (PARTITION BY block_number, event_index
)
SELECT
*
FROM
complete_data qualify(ROW_NUMBER() over (PARTITION BY block_number, event_index
ORDER BY
_inserted_timestamp DESC, is_pending ASC)) = 1

0 comments on commit 279b826

Please sign in to comment.