For the complete documentation index, see llms.txt. This page is also available as Markdown.

Macros

Macros make SQL dynamic with variables and functions. Overview of Vulcan macros, Jinja macros, and the predefined variables both systems share.

SQL is a declarative language, which means you describe what you want, not how to get it. This provides clarity, but SQL doesn't have built-in features like variables or control flow (if-then statements, loops) that let your queries adapt to different situations.

Data models are dynamic. You need different behavior depending on context: maybe filter by a different date each day, or include different columns based on configuration. Macros make this possible.

Macros let you make your SQL dynamic. Instead of hardcoding values, you can use variables that get substituted at runtime. Instead of writing repetitive code, you can use functions that generate SQL for you.

Vulcan supports two macro systems, each with its own strengths:

  • Vulcan macros: Built specifically for SQL, with semantic understanding of your queries

  • Jinja macros: The popular templating system, useful if you're already familiar with it

Both systems can use the same pre-defined variables that Vulcan provides, like @execution_ds for the current execution date or @this_model for the current model name.

Next steps:

Last updated

Was this helpful?