This commit is contained in:
Eric Laurello 2023-12-20 17:16:46 -05:00
parent e3d5c58bf4
commit f03aaeb91c
2 changed files with 11 additions and 46 deletions

View File

@ -9,51 +9,16 @@
) }}
{% if execute %}
{% set query = """
CREATE OR REPLACE TEMPORARY TABLE silver.transfers__intermediate_tmp AS
SELECT
block_id,
block_timestamp,
tx_id,
tx_succeeded,
msg_group,
msg_sub_group,
msg_index,
msg_type,
attribute_key,
attribute_value,
_inserted_timestamp
FROM
""" ~ ref('silver__msg_attributes') ~ """
WHERE
(
attribute_key IN (
'acc_seq',
'amount'
)
OR msg_type IN (
'coin_spent',
'transfer',
'message',
'claim',
'ibc_transfer',
'write_acknowledgement'
)
)"""
%}
{% set query = """ CREATE OR REPLACE TEMPORARY TABLE silver.transfers__intermediate_tmp AS SELECT block_id, block_timestamp, tx_id, tx_succeeded, msg_group, msg_sub_group, msg_index, msg_type, attribute_key, attribute_value, _inserted_timestamp FROM """ ~ ref('silver__msg_attributes') ~ """ WHERE ( attribute_key IN ( 'acc_seq', 'amount' ) OR msg_type IN ( 'coin_spent', 'transfer', 'message', 'claim', 'ibc_transfer', 'write_acknowledgement' ) )""" %}
{% set incr = "" %}
{% if is_incremental() %}
{% set incr = """
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
""" ~ this ~ """
) - INTERVAL '24 HOURS'""" %}
{% endif %}
{% do run_query(query ~ incr) %}
{% if is_incremental() %}
{% set incr = """ AND _inserted_timestamp >= ( SELECT MAX( _inserted_timestamp ) FROM """ ~ this ~ """ ) - INTERVAL '24 HOURS'""" %}
{% endif %}
{% do run_query(
query ~ incr
) %}
{% endif %}
WITH base_atts AS (
@ -437,7 +402,7 @@ axl_tran AS (
foreign_address IS NOT NULL
{% if is_incremental() %}
AND _inserted_timestamp >= (
AND A._inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp

View File

@ -263,7 +263,7 @@ adjust AS (
),
token_3_amount
) AS token_3_amount,
_inserted_timestamp
A._inserted_timestamp
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}