mirror of
https://github.com/FlipsideCrypto/osmosis-models.git
synced 2026-02-06 18:06:45 +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
69 lines
1.4 KiB
SQL
69 lines
1.4 KiB
SQL
{{ config(
|
|
materialized = 'incremental',
|
|
unique_key = "_unique_key",
|
|
incremental_strategy = 'merge',
|
|
incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"],
|
|
merge_exclude_columns = ["inserted_timestamp"],
|
|
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE','modified_timestamp::DATE'],
|
|
tags = ['core']
|
|
) }}
|
|
|
|
SELECT
|
|
block_id,
|
|
block_timestamp,
|
|
tx_id,
|
|
tx_succeeded,
|
|
msg_group,
|
|
msg_sub_group,
|
|
msg_index,
|
|
msg_type,
|
|
b.index AS attribute_index,
|
|
COALESCE(
|
|
CASE
|
|
WHEN block_id < 12833808 THEN TRY_BASE64_DECODE_STRING(
|
|
b.value :key
|
|
)
|
|
END,
|
|
b.value :key
|
|
) :: STRING AS attribute_key,
|
|
COALESCE(
|
|
CASE
|
|
WHEN block_id < 12833808 THEN TRY_BASE64_DECODE_STRING(
|
|
b.value :value
|
|
)
|
|
END,
|
|
b.value :value
|
|
) :: STRING AS attribute_value,
|
|
_inserted_timestamp,
|
|
concat_ws(
|
|
'-',
|
|
tx_id,
|
|
msg_index,
|
|
attribute_index
|
|
) AS _unique_key,
|
|
{{ dbt_utils.generate_surrogate_key(['_unique_key']) }} AS msg_attributes_id,
|
|
SYSDATE() AS inserted_timestamp,
|
|
SYSDATE() AS modified_timestamp,
|
|
'{{ invocation_id }}' AS _invocation_id
|
|
FROM
|
|
{{ ref('silver__msgs') }} A,
|
|
LATERAL FLATTEN(
|
|
input => A.msg,
|
|
path => 'attributes'
|
|
) b
|
|
|
|
{% if is_incremental() %}
|
|
WHERE
|
|
_inserted_timestamp >= DATEADD(
|
|
'minute',
|
|
-30,(
|
|
SELECT
|
|
MAX(
|
|
_inserted_timestamp
|
|
)
|
|
FROM
|
|
{{ this }}
|
|
)
|
|
)
|
|
{% endif %}
|