upd partition macro

This commit is contained in:
Jack Forgash 2025-03-14 16:24:32 -06:00
parent 843f986274
commit 49cd3e60de
2 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,6 @@
{% macro partition_load_manual(
scope = 'no_buffer'
scope = 'no_buffer',
partition_field = '_partition_by_block_number'
) %}
{# if range_start and range_end not set in cli, default to earliest rpc data #}
{% set range_start = var(
@ -19,17 +20,17 @@
1
) %}
{% if scope == 'front' %}
_partition_by_block_number BETWEEN {{ range_start }} - (
{{ partition_field }} BETWEEN {{ range_start }} - (
10000 * {{ front_buffer }}
)
AND {{ range_end }}
{% elif scope == 'end' %}
_partition_by_block_number BETWEEN {{ range_start }}
{{ partition_field }} BETWEEN {{ range_start }}
AND {{ range_end }} + (
10000 * {{ end_buffer }}
) {% elif scope == 'no_buffer' %}
_partition_by_block_number BETWEEN {{ range_start }}
{{ partition_field }} BETWEEN {{ range_start }}
AND {{ range_end }}
{% else %}
TRUE

View File

@ -84,7 +84,7 @@ WITH txs_with_receipts AS (
{{ ref('silver__transactions_v2') }}
{% if var("MANUAL_FIX") %}
WHERE
{{ partition_load_manual('no_buffer') }}
{{ partition_load_manual('no_buffer', 'partition_key') }}
{% else %}
{% if is_incremental() %}
WHERE origin_block_timestamp :: DATE >= '{{min_bd}}'
@ -101,7 +101,7 @@ blocks AS (
{{ ref('silver__blocks_v2') }}
{% if var("MANUAL_FIX") %}
WHERE
{{ partition_load_manual('no_buffer') }}
{{ partition_load_manual('no_buffer', 'partition_key') }}
{% else %}
{% if is_incremental() %}
WHERE block_timestamp :: DATE >= '{{min_bd}}' :: DATE