Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add plus operator example to tags doc #6737

Merged
merged 9 commits into from
Jan 8, 2025
10 changes: 7 additions & 3 deletions website/docs/reference/node-selection/graph-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ title: "Graph operators"
---

### The "plus" operator
If placed at the front of the model selector, `+` will select all ancestors of the selected model and the model itself. If placed at the end of the string, `+` will select all descendants of the selected model and the model itself.
The `+` operator expands your selection to include ancestors (upstream dependencies) or descendants (downstream dependencies) of a resource. This operator works for individual models, tags, and other resources.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow I understand now! SO MUCH better.


- Placed after a model/resource — Includes the resource itself and all its descendants (downstream dependencies).
- Placed before a model/resource — Includes the resource itself and all its ancestors (upstream dependencies).
- Placed on both sides of a model/resource — Includes the resource itself, all its ancestors, and all its descendants.

```bash
```bash
dbt run --select "my_model+" # select my_model and all descendants
dbt run --select "+my_model" # select my_model and all ancestors
dbt run --select "+my_model+" # select my_model, and all of its ancestors and descendants
```
```

You can use it with selectors for a more specific scope in your commands. You can also combine it with [`--exclude`](/reference/node-selection/exclude) flag for even more finer control over what gets included in your command.

### The "n-plus" operator

Expand Down
17 changes: 12 additions & 5 deletions website/docs/reference/resource-configs/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,18 @@ resource_type:
Apply a tag (or list of tags) to a resource.

These tags can be used as part of the [resource selection syntax](/reference/node-selection/syntax), when running the following commands:
- `dbt run --select tag:my_tag`
- `dbt build --select tag:my_tag`
- `dbt seed --select tag:my_tag`
- `dbt snapshot --select tag:my_tag`
- `dbt test --select tag:my_tag` (indirectly runs all tests associated with the models that are tagged)
- `dbt run --select tag:my_tag` — Run all models tagged with a specific tag.
- `dbt build --select tag:my_tag` — Build all resources tagged with a specific tag.
- `dbt seed --select tag:my_tag` — Seed all resources tagged with a specific tag.
- `dbt snapshot --select tag:my_tag` — Snapshot all resources tagged with a specific tag.
- `dbt test --select tag:my_tag` — Indirectly runs all tests associated with the models that are tagged.

#### Using tags with the `+` operator
You can use the [`+` operator](/reference/node-selection/graph-operators#the-plus-operator) to include upstream or downstream dependencies in your `tag` selection:
- `dbt run --select tag:my_tag+` — Run models tagged with `my_tag` and all their downstream dependencies.
- `dbt run --select +tag:my_tag` — Run models tagged with `my_tag` and all their upstream dependencies.
- `dbt run --select +model_name+` — Run a model, its upstream dependencies, and its downstream dependencies.
- `dbt run --select tag:my_tag+ --exclude tag:exclude_tag` — Run model tagged with `my_tag` and their downstream dependencies, and exclude models tagged with `exclude_tag`, regardless of their dependencies.

## Examples
### Use tags to run parts of your project
Expand Down
Loading