mirror of
https://github.com/FlipsideCrypto/cosmos-models.git
synced 2026-02-06 13:56:46 +00:00
bronze
This commit is contained in:
parent
d817d99d0d
commit
b084f7e279
@ -93,15 +93,16 @@ JOIN LATERAL FLATTEN(
|
||||
DATA :result :txs,
|
||||
outer => TRUE
|
||||
) t
|
||||
WHERE
|
||||
block_id > 20637874
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
qualify(ROW_NUMBER() over(PARTITION BY block_id_requested, tx_id
|
||||
|
||||
@ -6,8 +6,37 @@
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
|
||||
) }}
|
||||
|
||||
WITH base_transactions AS (
|
||||
WITH old_base_transactions AS (
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
t.value :hash :: STRING AS tx_id,
|
||||
t.value :tx_result :codespace AS codespace,
|
||||
t.value :tx_result :gas_used :: NUMBER AS gas_used,
|
||||
t.value :tx_result :gas_wanted :: NUMBER AS gas_wanted,
|
||||
CASE
|
||||
WHEN t.value :tx_result :code :: NUMBER = 0 THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
t.value :tx_result :code :: NUMBER AS tx_code,
|
||||
t.value :tx_result :events AS msgs,
|
||||
t.value :tx_result :log :: STRING AS tx_log,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ ref('bronze__tx_search') }},
|
||||
TABLE(FLATTEN(DATA :result :txs)) t
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp :: DATE >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) :: DATE - 2
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
base_transactions AS (
|
||||
SELECT
|
||||
block_id,
|
||||
tx_id,
|
||||
@ -17,7 +46,7 @@ WITH base_transactions AS (
|
||||
tx_succeeded,
|
||||
tx_code,
|
||||
msgs,
|
||||
tx_log,
|
||||
tx_log :: STRING AS tx_log,
|
||||
TO_TIMESTAMP(
|
||||
_inserted_timestamp
|
||||
) AS _inserted_timestamp
|
||||
@ -32,6 +61,35 @@ WHERE
|
||||
FROM
|
||||
{{ this }})
|
||||
{% endif %}
|
||||
),
|
||||
combo AS (
|
||||
SELECT
|
||||
block_id,
|
||||
tx_id,
|
||||
codespace,
|
||||
gas_used,
|
||||
gas_wanted,
|
||||
tx_succeeded,
|
||||
tx_code,
|
||||
msgs,
|
||||
tx_log,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
base_transactions
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_id,
|
||||
tx_id,
|
||||
codespace,
|
||||
gas_used,
|
||||
gas_wanted,
|
||||
tx_succeeded,
|
||||
tx_code,
|
||||
msgs,
|
||||
tx_log,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
old_base_transactions
|
||||
)
|
||||
SELECT
|
||||
t.block_id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user