mirror of
https://github.com/FlipsideCrypto/osmosis-models.git
synced 2026-02-06 15:56:44 +00:00
Some checks failed
docs_update / run_dbt_jobs (push) Has been cancelled
docs_update / notify-failure (push) Has been cancelled
dbt_run_daily / run_dbt_jobs (push) Has been cancelled
dbt_run_dev_refresh / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_balances / run_dbt_jobs (push) Has been cancelled
dbt_run_daily / notify-failure (push) Has been cancelled
dbt_run_streamline_balances / notify-failure (push) Has been cancelled
dbt_test_scheduled / run_dbt_jobs (push) Has been cancelled
dbt_test_scheduled / notify-failure (push) Has been cancelled
dbt_run_incremental_core / run_dbt_jobs (push) Has been cancelled
dbt_run_incremental_non_core / run_dbt_jobs (push) Has been cancelled
dbt_run_udf_blockchain / run_dbt_jobs (push) Has been cancelled
dbt_run_incremental_core / notify-failure (push) Has been cancelled
dbt_run_incremental_non_core / notify-failure (push) Has been cancelled
dbt_run_udf_blockchain / notify-failure (push) Has been cancelled
dbt_run_observability / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_transactions_realtime / run_dbt_jobs (push) Has been cancelled
dbt_run_observability / notify-failure (push) Has been cancelled
dbt_run_streamline_transactions_realtime / notify-failure (push) Has been cancelled
dbt_run_streamline_blocks_txcount_realtime / run_dbt_jobs (push) Has been cancelled
dbt_run_streamline_blocks_txcount_realtime / notify-failure (push) Has been cancelled
51 lines
1.2 KiB
SQL
51 lines
1.2 KiB
SQL
{{ config(
|
|
materialized = 'incremental',
|
|
unique_key = ['tx_id','_body_index'],
|
|
incremental_strategy = 'delete+insert',
|
|
cluster_by = ['block_timestamp::DATE'],
|
|
tags = ['noncore']
|
|
) }}
|
|
|
|
SELECT
|
|
block_id,
|
|
block_timestamp,
|
|
tx_id,
|
|
tx_succeeded,
|
|
trader,
|
|
from_amount,
|
|
from_currency,
|
|
as_f.decimal AS from_decimal,
|
|
to_amount,
|
|
to_currency,
|
|
as_t.decimal AS TO_DECIMAL,
|
|
pool_id :: ARRAY AS pool_ids,
|
|
pool_id :: INT AS pool_id,
|
|
msg_index AS _body_index,
|
|
{{ dbt_utils.generate_surrogate_key(
|
|
['tx_id','msg_index']
|
|
) }} AS swaps_id,
|
|
SYSDATE() AS inserted_timestamp,
|
|
SYSDATE() AS modified_timestamp,
|
|
A._inserted_timestamp,
|
|
'{{ invocation_id }}' AS _invocation_id
|
|
FROM
|
|
{{ ref('silver__token_swapped') }} A
|
|
LEFT OUTER JOIN {{ ref('silver__asset_metadata') }}
|
|
as_f
|
|
ON A.from_currency = as_f.address
|
|
LEFT OUTER JOIN {{ ref('silver__asset_metadata') }}
|
|
as_t
|
|
ON A.to_currency = as_t.address
|
|
|
|
{% if is_incremental() %}
|
|
WHERE
|
|
A._inserted_timestamp >= (
|
|
SELECT
|
|
MAX(
|
|
_inserted_timestamp
|
|
)
|
|
FROM
|
|
{{ this }}
|
|
)
|
|
{% endif %}
|