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

links to graph operators #4618

Merged
merged 9 commits into from
Dec 12, 2023
29 changes: 23 additions & 6 deletions website/docs/reference/node-selection/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ 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 for select flag">
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

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

1. a package name
Expand All @@ -52,21 +56,30 @@ 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
```
```

</TabItem>

dbt supports a shorthand language for defining subsets of nodes. This language uses the characters `+`, `@`, `*`, and `,`.
<TabItem value="subset" label="Examples for subsets of nodes">
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

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

```bash
- plus operator [(`+`)](/reference/node-selection/graph-operators#the-plus-operator)
- at operator [(`@`)](/reference/node-selection/graph-operators#the-at-operator)
- asterisk operator (`*`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have issues to create content for the * and , operators?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i dont think so, i was going to create an issue to add the asterisk and comma operator tomorrow, however if you want to tackle that - feel free!

- comma operator (`,`)

Examples:

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

Expand All @@ -77,6 +90,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
Loading