mirror of
https://github.com/FlipsideCrypto/cosmos-models.git
synced 2026-02-06 13:56:46 +00:00
Some checks failed
docs_update / run_dbt_jobs (push) Has been cancelled
docs_update / notify-failure (push) Has been cancelled
dbt_run_observability / run_dbt_jobs (push) Has been cancelled
dbt_run_observability / notify-failure (push) Has been cancelled
dbt_run_dev_refresh / run_dbt_jobs (push) Has been cancelled
dbt_test_scheduled / run_dbt_jobs (push) Has been cancelled
dbt_test_scheduled / notify-failure (push) Has been cancelled
dbt_run_udf_blockchain / run_dbt_jobs (push) Has been cancelled
dbt_run_udf_blockchain / notify-failure (push) Has been cancelled
37 lines
956 B
SQL
37 lines
956 B
SQL
-- depends_on: {{ ref('bronze__streamline_blocks') }}
|
|
{{ config (
|
|
materialized = "incremental",
|
|
incremental_strategy = 'merge',
|
|
unique_key = "block_number",
|
|
cluster_by = "ROUND(block_number, -3)",
|
|
merge_exclude_columns = ["inserted_timestamp"],
|
|
) }}
|
|
|
|
SELECT
|
|
DATA :result :block :header :height :: INT AS block_number,
|
|
{{ dbt_utils.generate_surrogate_key(
|
|
['block_number']
|
|
) }} AS complete_blocks_id,
|
|
SYSDATE() AS inserted_timestamp,
|
|
SYSDATE() AS modified_timestamp,
|
|
file_name,
|
|
'{{ invocation_id }}' AS _invocation_id
|
|
FROM
|
|
|
|
{% if is_incremental() %}
|
|
{{ ref('bronze__streamline_blocks') }}
|
|
WHERE
|
|
inserted_timestamp >= (
|
|
SELECT
|
|
MAX(modified_timestamp) modified_timestamp
|
|
FROM
|
|
{{ this }}
|
|
)
|
|
{% else %}
|
|
{{ ref('bronze__streamline_FR_blocks') }}
|
|
{% endif %}
|
|
|
|
qualify(ROW_NUMBER() over (PARTITION BY block_number
|
|
ORDER BY
|
|
inserted_timestamp DESC)) = 1
|