# Tags

Tags in dex allow you to **organize, classify, and filter models** based on custom labels. They help teams manage large projects by grouping models by purpose, domain, update frequency, team ownership, or deployment behavior.

Tags are especially useful when:

* You want to run only a subset of models in a Flow
* You need to isolate models owned by a specific team or department
* You want to flag models for a specific DAG layer (e.g. `gold`, `finance`, `staging`)
* You need to run models with specific update schedules (e.g. hourly vs. daily)

Tags are simple, flexible, and easy to apply—yet powerful when used with dex’s orchestration, lineage, and filtering features.

### How to Add Tags

Tags are defined in your model using the `config()` block:

```sql
{{ config(
    materialized='table',
    tags=['daily', 'finance']
) }}

select *
from {{ ref('orders') }}
```

You can assign one or more tags to a model. Tags must be provided as a list of strings.

### Where Tags Are Used

Tags in dex can be used in:

* **Flows**: to run only models with a given tag (e.g. all `daily` jobs or all `marketing` models)
* **Lineage and Explorer**: to visually filter and group models by tag
* **Build and CI/CD workflows**: to include or exclude specific sets of models
* **Governance**: to apply review policies, ownership boundaries, or SLA labels

### Example Use Cases

### Example Use Cases

| Tag          | Purpose                                          |
| ------------ | ------------------------------------------------ |
| `finance`    | Identify models used in financial reporting      |
| `daily`      | Run this model on a daily schedule               |
| `deprecated` | Flag a model for future removal                  |
| `staging`    | Mark this as a staging-layer model               |
| `ml_inputs`  | Used in machine learning feature pipelines       |
| `external`   | Consumes data from a third-party or external API |

You can create your own taxonomy of tags to reflect how your team thinks about and manages data.

### Filtering by Tag in Flows

When configuring a Flow, you can choose to run:

* All models
* Specific models
* Models that have a given **tag**

This is useful for setting up specialized Flows such as:

* Running only `hourly` jobs
* Rebuilding all `gold` layer models
* Testing only `experimental` models in a dev environment

### Example Project Snippet

```plsql
{{ config(
    materialized='incremental',
    tags=['ml_inputs', 'hourly']
) }}

select
  customer_id,
  avg(session_length) as avg_session_time
from {{ ref('web_sessions') }}
group by customer_id

```

This model is tagged for use in both machine learning pipelines and hourly flows.

### Best Practices

* Use lowercase, underscore-separated names (e.g. `marketing_reports`, not `MarketingReports`)
* Keep your tag vocabulary consistent across the project
* Use tags to reflect functional or operational intent (e.g. `hourly`, `external`, `mart`)
* Combine tags with documentation for better discoverability
* Regularly clean up unused or outdated tags


---

# Agent Instructions: 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:

```
GET https://docs.dexlabs.io/lakehouse-platform/develop-with-dex/tags.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
