Skip to main content

Module tera

Module tera 

Source
Expand description

Tera template engine setup and custom functions

This module configures the Tera template engine for rendering SQL templates. It provides:

  • Template loading from the working directory
  • Custom Tera functions (e.g., date_range)

ยงCustom Functions

ยงdate_range

Generates a list of dates between start and end dates (exclusive of end).

{% set start_date = "2022-01-01" %}
{% set end_date = "2022-01-05" %}
{% for date in date_range(start=start_date, end=end_date) %}
  PARTITION (date='{{ date }}')
{% endfor %}

This generates:

PARTITION (date='2022-01-01')
PARTITION (date='2022-01-02')
PARTITION (date='2022-01-03')
PARTITION (date='2022-01-04')

Constantsยง

DATE_FORMAT ๐Ÿ”’
SQL_FILE_EXTENSION ๐Ÿ”’

Functionsยง

date_range
get_native_date ๐Ÿ”’
get_tera
Get Tera template, load the template from working dir