2022-02-28 23:55:44 +00:00
|
|
|
{{ config(
|
|
|
|
|
materialized = 'incremental',
|
|
|
|
|
unique_key = "CONCAT_WS('-', block_id, tx_id)",
|
|
|
|
|
incremental_strategy = 'delete+insert',
|
2022-07-13 21:16:48 +00:00
|
|
|
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'],
|
2022-02-28 23:55:44 +00:00
|
|
|
) }}
|
|
|
|
|
|
|
|
|
|
WITH base AS (
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
block_timestamp,
|
|
|
|
|
block_id,
|
|
|
|
|
tx_id,
|
2022-03-04 18:22:19 +00:00
|
|
|
tx :transaction :message :recentBlockhash :: STRING AS recent_block_hash,
|
|
|
|
|
tx :meta :fee :: NUMBER AS fee,
|
2022-02-28 23:55:44 +00:00
|
|
|
CASE
|
2022-06-23 16:46:56 +00:00
|
|
|
WHEN IS_NULL_VALUE(
|
|
|
|
|
tx :meta :err
|
|
|
|
|
) THEN TRUE
|
2022-02-28 23:55:44 +00:00
|
|
|
ELSE FALSE
|
|
|
|
|
END AS succeeded,
|
|
|
|
|
tx :transaction :message :instructions [0] :parsed :info :voteAccount :: STRING AS vote_account,
|
|
|
|
|
tx :transaction :message :instructions [0] :parsed :info :voteAuthority :: STRING AS vote_authority,
|
2022-03-04 18:22:19 +00:00
|
|
|
tx :transaction :message :instructions [0] :parsed :info :vote :hash :: STRING AS vote_hash,
|
|
|
|
|
tx :transaction :message :instructions [0] :parsed :info :vote :slots :: ARRAY AS vote_slots,
|
2022-06-22 13:13:44 +00:00
|
|
|
ingested_at,
|
|
|
|
|
_inserted_timestamp
|
2022-02-28 23:55:44 +00:00
|
|
|
FROM
|
2022-03-01 22:51:37 +00:00
|
|
|
{{ ref('bronze__transactions') }}
|
2022-02-28 23:55:44 +00:00
|
|
|
t
|
|
|
|
|
WHERE
|
|
|
|
|
tx :transaction :message :instructions [0] :parsed :type :: STRING IS NOT NULL
|
|
|
|
|
AND tx :transaction :message :instructions [0] :programId :: STRING = 'Vote111111111111111111111111111111111111111'
|
2022-03-02 01:42:47 +00:00
|
|
|
|
|
|
|
|
{% if is_incremental() %}
|
2022-06-23 16:46:56 +00:00
|
|
|
AND _inserted_timestamp >= (
|
|
|
|
|
SELECT
|
|
|
|
|
MAX(_inserted_timestamp)
|
|
|
|
|
FROM
|
|
|
|
|
{{ this }}
|
|
|
|
|
)
|
2022-03-02 01:42:47 +00:00
|
|
|
{% endif %}
|
2022-02-28 23:55:44 +00:00
|
|
|
)
|
|
|
|
|
SELECT
|
|
|
|
|
block_timestamp,
|
|
|
|
|
block_id,
|
|
|
|
|
tx_id,
|
|
|
|
|
recent_block_hash,
|
2022-03-02 19:33:01 +00:00
|
|
|
fee,
|
2022-02-28 23:55:44 +00:00
|
|
|
succeeded,
|
|
|
|
|
vote_account,
|
|
|
|
|
vote_authority,
|
|
|
|
|
vote_hash,
|
|
|
|
|
vote_slots,
|
2022-06-22 13:13:44 +00:00
|
|
|
ingested_at,
|
|
|
|
|
_inserted_timestamp
|
2022-02-28 23:55:44 +00:00
|
|
|
FROM
|
2022-03-01 22:51:37 +00:00
|
|
|
base qualify(ROW_NUMBER() over(PARTITION BY block_id, tx_id
|
2022-02-28 23:55:44 +00:00
|
|
|
ORDER BY
|
2022-06-23 16:46:56 +00:00
|
|
|
_inserted_timestamp DESC)) = 1
|