mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 13:56:44 +00:00
silver_v2 - kill so, kill chunks_
This commit is contained in:
parent
5f14b1440a
commit
0b00ccabaa
@ -6,7 +6,6 @@
|
||||
incremental_predicates = ["dynamic_range_predicate","block_timestamp::date"],
|
||||
unique_key = "block_hash",
|
||||
cluster_by = ['modified_timestamp::DATE','block_timestamp::date'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION on equality(block_hash)",
|
||||
tags = ['scheduled_core', 'core_v2']
|
||||
) }}
|
||||
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
-- depends_on: {{ ref('bronze__chunks') }}
|
||||
-- depends_on: {{ ref('bronze__FR_chunks') }}
|
||||
{{ config (
|
||||
materialized = "incremental",
|
||||
incremental_strategy = 'merge',
|
||||
incremental_predicates = ["dynamic_range_predicate","block_timestamp::date"],
|
||||
unique_key = "chunk_hash",
|
||||
cluster_by = ['modified_timestamp::DATE','block_timestamp::date'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION on equality(chunk_hash)",
|
||||
tags = ['scheduled_core', 'core_v2']
|
||||
) }}
|
||||
-- TODO this can actually be dropped
|
||||
-- chunks only needed intrapipeline to get tx hashes
|
||||
-- unless deployed to a fact_chunks table with just the header ? ...
|
||||
-- chunk author might be helpful to analysts looking at validator performance
|
||||
-- the rest of the chunk header is contained in the block json
|
||||
-- truly just chunk author ...
|
||||
|
||||
WITH bronze_chunks AS (
|
||||
|
||||
SELECT
|
||||
VALUE :BLOCK_ID :: INT AS block_id,
|
||||
VALUE :BLOCK_TIMESTAMP_EPOCH :: INT AS block_timestamp_epoch,
|
||||
DATA :header :shard_id :: INT AS shard_id,
|
||||
DATA :header :chunk_hash :: STRING AS chunk_hash,
|
||||
partition_key,
|
||||
DATA :: variant AS chunk_json,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
|
||||
{% if is_incremental() %}
|
||||
{{ ref('bronze__chunks') }}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
COALESCE(MAX(_inserted_timestamp), '1900-01-01' :: TIMESTAMP) AS _inserted_timestamp
|
||||
FROM
|
||||
{{ this }})
|
||||
AND typeof(DATA) != 'NULL_VALUE'
|
||||
{% else %}
|
||||
{{ ref('bronze__FR_chunks') }}
|
||||
WHERE
|
||||
typeof(DATA) != 'NULL_VALUE'
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp_epoch,
|
||||
TO_TIMESTAMP_NTZ(block_timestamp_epoch, 9) AS block_timestamp,
|
||||
shard_id,
|
||||
chunk_hash,
|
||||
partition_key,
|
||||
chunk_json,
|
||||
_inserted_timestamp,
|
||||
{{ dbt_utils.generate_surrogate_key(['chunk_hash']) }} AS chunks_v2_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
bronze_chunks
|
||||
|
||||
qualify ROW_NUMBER() over (
|
||||
PARTITION BY chunk_hash
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC
|
||||
) = 1
|
||||
@ -6,7 +6,6 @@
|
||||
incremental_predicates = ["dynamic_range_predicate","origin_block_timestamp::date"],
|
||||
unique_key = "tx_hash",
|
||||
cluster_by = ['modified_timestamp::DATE','origin_block_timestamp::date'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION on equality(tx_hash)",
|
||||
tags = ['scheduled_core', 'core_v2']
|
||||
) }}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user