osmosis-models/models/silver/silver__tx_body_msgs.sql
eric-laurello e3482847d3
AN-2245 superfluid staked balances (#64)
* check in

* WIP check in

* WIP check in

* locked LP actions and balances

* add business logic test, fix test failure & typos

* ds store

* ds store

* more logic tests
2022-10-21 13:18:58 -04:00

57 lines
867 B
SQL

{{ config(
materialized = 'incremental',
unique_key = "_unique_key",
incremental_strategy = 'merge',
cluster_by = ['_inserted_timestamp::DATE']
) }}
WITH b AS (
SELECT
block_id,
block_timestamp,
blockchain,
chain_id,
tx_id,
tx_status,
INDEX AS msg_group,
VALUE :"@type" :: STRING AS msg_type,
VALUE AS msg,
_inserted_timestamp
FROM
{{ ref('silver__transactions') }} A,
LATERAL FLATTEN(
input => A.tx_body :messages
)
{% if is_incremental() %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_id,
block_timestamp,
blockchain,
chain_id,
tx_id,
tx_status,
msg_group,
msg_type,
msg,
concat_ws(
'-',
tx_id,
msg_group
) AS _unique_key,
_inserted_timestamp
FROM
b