> For the complete documentation index, see [llms.txt](https://v2.dataos.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://v2.dataos.info/references/resources/vulcan/advanced-features/macros.md).

# 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](https://en.wikipedia.org/wiki/Declarative_programming), 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](https://v2.dataos.info/references/resources/vulcan/advanced-features/macros/variables.md) that Vulcan provides, like `@execution_ds` for the current execution date or `@this_model` for the current model name.

Next steps:

* [Pre-defined macro variables](https://v2.dataos.info/references/resources/vulcan/advanced-features/macros/variables.md) - Built-in variables available in both systems
* [Vulcan macros](https://v2.dataos.info/references/resources/vulcan/advanced-features/macros/built-in.md) - Vulcan's native macro system with SQL-aware features
* [Jinja macros](https://v2.dataos.info/references/resources/vulcan/advanced-features/macros/jinja.md) - The Jinja templating system for SQL


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://v2.dataos.info/references/resources/vulcan/advanced-features/macros.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
