mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 13:56:44 +00:00
rm stake and state from this branch
This commit is contained in:
parent
f48af7d3e8
commit
a4d173b9d0
@ -1,69 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_predicates = ['DBT_INTERNAL_DEST._partition_by_block_number >= (select min(_partition_by_block_number) from ' ~ generate_tmp_view_name(this) ~ ')'],
|
||||
incremental_strategy = 'merge',
|
||||
merge_exclude_columns = ['inserted_timestamp'],
|
||||
unique_key = 'state_change_id',
|
||||
cluster_by = ['modified_timestamp::date', '_partition_by_block_number']
|
||||
) }}
|
||||
-- https://app.snowflake.com/zsniary/exa10207/#/compute/history/queries/01b73a95-0411-29e0-3d4f-83027386d7bb/detail
|
||||
-- Took 3h16m on 2XL
|
||||
WITH shards AS (
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
shard_id,
|
||||
state_changes,
|
||||
_partition_by_block_number,
|
||||
COALESCE(
|
||||
modified_timestamp,
|
||||
_inserted_timestamp
|
||||
) AS _modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__streamline_shards') }}
|
||||
WHERE
|
||||
ARRAY_SIZE(state_changes) > 0
|
||||
|
||||
{% if var('MANUAL_FIX') %}
|
||||
AND {{ partition_load_manual('no_buffer') }}
|
||||
{% else %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
),
|
||||
flatten_state_change AS (
|
||||
SELECT
|
||||
block_id,
|
||||
shard_id,
|
||||
VALUE,
|
||||
INDEX,
|
||||
VALUE :cause :: variant AS state_change_cause,
|
||||
VALUE :change :: variant AS state_changes,
|
||||
VALUE :type :: STRING AS state_change_type,
|
||||
_partition_by_block_number
|
||||
FROM
|
||||
shards,
|
||||
LATERAL FLATTEN (state_changes)
|
||||
)
|
||||
SELECT
|
||||
block_id,
|
||||
shard_id,
|
||||
value,
|
||||
index,
|
||||
state_change_cause,
|
||||
state_changes,
|
||||
state_change_type,
|
||||
_partition_by_block_number,
|
||||
{{ dbt_utils.generate_surrogate_key(['shard_id', 'index::STRING']) }} AS state_change_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
flatten_state_change
|
||||
@ -1,74 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
incremental_predicates = ["COALESCE(DBT_INTERNAL_DEST.block_timestamp::DATE,'2099-12-31') >= (select min(block_timestamp::DATE) from " ~ generate_tmp_view_name(this) ~ ")"],
|
||||
cluster_by = ['block_timestamp::DATE', 'modified_timestamp::DATE'],
|
||||
unique_key = 'token_transfer_stake_id',
|
||||
incremental_strategy = 'merge',
|
||||
tags = ['curated','scheduled_non_core']
|
||||
) }}
|
||||
|
||||
WITH action_events AS(
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
action_id,
|
||||
tx_hash,
|
||||
action_data :public_key :: STRING AS public_key,
|
||||
action_data :stake :: STRING AS amount_unadj,
|
||||
predecessor_id,
|
||||
receiver_id,
|
||||
signer_id,
|
||||
receipt_succeeded,
|
||||
gas_price,
|
||||
gas_burnt,
|
||||
tokens_burnt,
|
||||
_partition_by_block_number,
|
||||
_inserted_timestamp,
|
||||
modified_timestamp AS _modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__actions_events_s3') }}
|
||||
WHERE
|
||||
action_name = 'Stake'
|
||||
{% if var("MANUAL_FIX") %}
|
||||
AND {{ partition_load_manual('no_buffer') }}
|
||||
{% else %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
action_id,
|
||||
tx_hash,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
public_key,
|
||||
amount_unadj,
|
||||
amount_unadj :: DOUBLE / pow(
|
||||
10,
|
||||
24
|
||||
) AS amount_adj,
|
||||
predecessor_id,
|
||||
receiver_id,
|
||||
signer_id,
|
||||
receipt_succeeded,
|
||||
gas_price,
|
||||
gas_burnt,
|
||||
tokens_burnt,
|
||||
_partition_by_block_number,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['action_id', 'predecessor_id', 'receiver_id', 'amount_unadj']
|
||||
) }} AS token_transfer_stake_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
action_events
|
||||
Loading…
Reference in New Issue
Block a user