Skip to content

Built-in Variables

Bruin automatically injects these variables into the Jinja context for templated assets (SQL, YAML parameters, and other templated fields).

Variable Reference

VariableDescriptionExample
start_dateStart date in YYYY-MM-DD format"2023-12-01"
start_date_nodashStart date in YYYYMMDD format"20231201"
start_datetimeStart date and time in YYYY-MM-DDThh:mm:ss format"2023-12-01T15:30:00"
start_timestampStart timestamp in RFC3339 format"2023-12-01T15:30:00.000000Z"
end_dateEnd date in YYYY-MM-DD format"2023-12-02"
end_date_nodashEnd date in YYYYMMDD format"20231202"
end_datetimeEnd date and time in YYYY-MM-DDThh:mm:ss format"2023-12-02T15:30:00"
end_timestampEnd timestamp in RFC3339 format"2023-12-02T15:30:00.000000Z"
execution_dateExecution date in YYYY-MM-DD format"2023-12-01"
execution_date_nodashExecution date in YYYYMMDD format"20231201"
execution_datetimeExecution date and time in YYYY-MM-DDThh:mm:ss format"2023-12-01T15:30:00"
execution_timestampExecution timestamp in RFC3339 format"2023-12-01T15:30:00.000000Z"
pipelineName of the currently executing pipeline"my_pipeline"
run_idUnique identifier for the current pipeline run"run_1234567890"
full_refreshWhether the run is a full refreshtrue
commit_hashThe current git commit hash of the pipeline's repository"abc1234def5678..."

Using Built-in Variables in SQL

bruin-sql
/* @bruin
name: analytics.daily_summary
type: duckdb.sql
@bruin */

SELECT
    '{{ execution_date }}' as report_date,
    '{{ pipeline }}' as pipeline_name,
    COUNT(*) as total_events
FROM events
WHERE event_date >= '{{ start_date }}'
  AND event_date < '{{ end_date }}'

Using Built-in Variables in Python

Built-in variables are exposed as environment variables with a BRUIN_ prefix:

python
"""@bruin
name: my_python_asset
@bruin"""

import os

start_date = os.environ["BRUIN_START_DATE"]
end_date = os.environ["BRUIN_END_DATE"]
pipeline_name = os.environ["BRUIN_PIPELINE"]
run_id = os.environ["BRUIN_RUN_ID"]

print(f"Processing {pipeline_name} for {start_date} to {end_date}")

Python Environment Variable Mapping

Jinja VariablePython Environment Variable
start_dateBRUIN_START_DATE
start_datetimeBRUIN_START_DATETIME
start_timestampBRUIN_START_TIMESTAMP
end_dateBRUIN_END_DATE
end_datetimeBRUIN_END_DATETIME
end_timestampBRUIN_END_TIMESTAMP
execution_dateBRUIN_EXECUTION_DATE
execution_datetimeBRUIN_EXECUTION_DATETIME
execution_timestampBRUIN_EXECUTION_TIMESTAMP
pipelineBRUIN_PIPELINE
run_idBRUIN_RUN_ID
full_refreshBRUIN_FULL_REFRESH ("1" or "0")
commit_hashBRUIN_COMMIT_HASH

NOTE

The _nodash variants (start_date_nodash, end_date_nodash, execution_date_nodash) are only available in the Jinja context for SQL assets. They are not exposed as Python environment variables. If you need a nodash format in Python, derive it from the date string: start_date.replace("-", "").