> 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/concepts/resources/vulcan/components/advanced-features/macros.md).

# Macros

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.

The problem? 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. That's where macros come in.

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](/concepts/resources/vulcan/components/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](/concepts/resources/vulcan/components/advanced-features/macros/variables.md) - Built-in variables available in both systems
* [Vulcan macros](/concepts/resources/vulcan/components/advanced-features/macros/built_in.md) - Vulcan's native macro system with SQL-aware features
* [Jinja macros](/concepts/resources/vulcan/components/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
