Skip to content

Commit

Permalink
links to graph operators (#4618)
Browse files Browse the repository at this point in the history
per [slack
therad](https://dbt-labs.slack.com/archives/C05FWBP9X1U/p1702275981683689),
this PR spells out the graph operators and links to their links so users
don't have to manually search for them. this pr also turns the examples
into tabs for easier scrolling/navigation.
  • Loading branch information
mirnawong1 authored Dec 12, 2023
2 parents 46a3a5c + bdedce4 commit 47be36e
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions website/docs/reference/node-selection/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ To follow [POSIX standards](https://pubs.opengroup.org/onlinepubs/9699919799/bas

3. dbt now has a list of still-selected resources of varying types. As a final step, it tosses away any resource that does not match the resource type of the current task. (Only seeds are kept for `dbt seed`, only models for `dbt run`, only tests for `dbt test`, and so on.)

### Shorthand
## Shorthand

Select resources to build (run, test, seed, snapshot) or check freshness: `--select`, `-s`

### Examples

By default, `dbt run` will execute _all_ of the models in the dependency graph. During development (and deployment), it is useful to specify only a subset of models to run. Use the `--select` flag with `dbt run` to select a subset of models to run. Note that the following arguments (`--select`, `--exclude`, and `--selector`) also apply to other dbt tasks, such as `test` and `build`.

<Tabs>
<TabItem value="select" label="Examples of select flag">

The `--select` flag accepts one or more arguments. Each argument can be one of:

1. a package name
Expand All @@ -52,23 +55,38 @@ The `--select` flag accepts one or more arguments. Each argument can be one of:

Examples:


```bash
```bash
dbt run --select "my_dbt_project_name" # runs all models in your project
dbt run --select "my_dbt_model" # runs a specific model
dbt run --select "path.to.my.models" # runs all models in a specific directory
dbt run --select "my_package.some_model" # run a specific model in a specific package
dbt run --select "tag:nightly" # run models with the "nightly" tag
dbt run --select "path/to/models" # run models contained in path/to/models
dbt run --select "path/to/my_model.sql" # run a specific model by its path
```
```

dbt supports a shorthand language for defining subsets of nodes. This language uses the characters `+`, `@`, `*`, and `,`.
</TabItem>

<TabItem value="subset" label="Examples of subsets of nodes">

```bash
dbt supports a shorthand language for defining subsets of nodes. This language uses the following characters:

- plus operator [(`+`)](/reference/node-selection/graph-operators#the-plus-operator)
- at operator [(`@`)](/reference/node-selection/graph-operators#the-at-operator)
- asterisk operator (`*`)
- comma operator (`,`)

Examples:

```bash
# multiple arguments can be provided to --select
dbt run --select "my_first_model my_second_model"
dbt run --select "my_first_model my_second_model"

# select my_model and all of its children
dbt run --select "my_model+"

# select my_model, its children, and the parents of its children
dbt run --models @my_model

# these arguments can be projects, models, directory paths, tags, or sources
dbt run --select "tag:nightly my_model finance.base.*"
Expand All @@ -77,6 +95,10 @@ dbt run --select "tag:nightly my_model finance.base.*"
dbt run --select "path:marts/finance,tag:nightly,config.materialized:table"
```

</TabItem>

</Tabs>

As your selection logic gets more complex, and becomes unwieldly to type out as command-line arguments,
consider using a [yaml selector](/reference/node-selection/yaml-selectors). You can use a predefined definition with the `--selector` flag.
Note that when you're using `--selector`, most other flags (namely `--select` and `--exclude`) will be ignored.
Expand Down

0 comments on commit 47be36e

Please sign in to comment.