Skip to content

Filters

Bruin supports Jinja filters to modify any given variable before they are converted to SQL. Filters are separated from the variable by a pipe symbol (|) and may have optional arguments in parentheses. Multiple filters can be chained. The output of one filter is applied to the next.

sql
SELECT * FROM my_table WHERE dt BETWEEN '{{ start_date |  date_format('%Y-%m-%d') }}' AND '{{ end_date | date_format('%Y-%m-%d') }}'

Default Filters

Bruin CLI supports various default filters supported by Jinja, you can see the list here.

Date Filters

Bruin supports various date-related filters to format dates that can be chained together.

date_add

Adds given number of days to the date.

jinja
{{ end_datetime | date_add(3) }}

For a given datetime 2022-02-07T04:00:00.948740Z, this results in the following string:

2022-02-10T04:00:00.948740Z

You can also give negative numbers to subtract days.

date_format

Formats the date according to the given format string.

jinja
{{ end_datetime | date_format('%Y-%m-%d') }}

For a given datetime 2022-02-07T04:00:00.948740Z, this results in the following string:

2022-02-07

The format given here follows Python date formatting rules, you can see the list here.