Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:03:06 +08:00
commit 73652b90f9
8 changed files with 2794 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
-- TD Incremental Scan Macro
-- Scans a table for a specific time range and optionally filters for incremental processing
-- Default target_range is '-3M/now' (last 3 months to now)
{% macro incremental_scan(table_name) -%}
(
SELECT * FROM {{ table_name }}
WHERE TD_INTERVAL(time, '{{ var("target_range", "-3M/now") }}')
{% if is_incremental() -%}
AND time > {{ get_max_time(this.table) }}
{%- endif %}
)
{%- endmacro %}
{% macro get_max_time(table_name) -%}
(SELECT MAX(time) FROM {{ table_name }})
{%- endmacro %}