From 08972fe81b37c325692942689cbb772b6c4b67fe Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Mon, 11 Dec 2023 10:16:18 -0500 Subject: [PATCH 1/6] clarify and add links --- .../docs/reference/node-selection/syntax.md | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/website/docs/reference/node-selection/syntax.md b/website/docs/reference/node-selection/syntax.md index d0ea4a9acd8..14ec34eb8a6 100644 --- a/website/docs/reference/node-selection/syntax.md +++ b/website/docs/reference/node-selection/syntax.md @@ -35,7 +35,7 @@ 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` @@ -43,6 +43,10 @@ Select resources to build (run, test, seed, snapshot) or check freshness: `--sel 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`. + + + + The `--select` flag accepts one or more arguments. Each argument can be one of: 1. a package name @@ -52,8 +56,7 @@ 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 @@ -61,12 +64,20 @@ dbt run --select "my_package.some_model" # run a specific model in a specific pa 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 `,`. + + - ```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 (`,`) + +```bash # multiple arguments can be provided to --select dbt run --select "my_first_model my_second_model" @@ -77,6 +88,10 @@ dbt run --select "tag:nightly my_model finance.base.*" dbt run --select "path:marts/finance,tag:nightly,config.materialized:table" ``` + + + + 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. From e198da4b6fce4188af82c308544717d0590805ec Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Mon, 11 Dec 2023 10:16:59 -0500 Subject: [PATCH 2/6] add example --- website/docs/reference/node-selection/syntax.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/reference/node-selection/syntax.md b/website/docs/reference/node-selection/syntax.md index 14ec34eb8a6..1edc28a4c41 100644 --- a/website/docs/reference/node-selection/syntax.md +++ b/website/docs/reference/node-selection/syntax.md @@ -77,6 +77,8 @@ dbt supports a shorthand language for defining subsets of nodes. This language u - asterisk operator (`*`) - comma operator (`,`) +Examples: + ```bash # multiple arguments can be provided to --select dbt run --select "my_first_model my_second_model" From f4ceaf326758cc037e8ce2e2ee3bf56d9515a5fd Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Mon, 11 Dec 2023 10:26:59 -0500 Subject: [PATCH 3/6] fix label --- website/docs/reference/node-selection/syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/reference/node-selection/syntax.md b/website/docs/reference/node-selection/syntax.md index 1edc28a4c41..31e4f878ff3 100644 --- a/website/docs/reference/node-selection/syntax.md +++ b/website/docs/reference/node-selection/syntax.md @@ -45,7 +45,7 @@ By default, `dbt run` will execute _all_ of the models in the dependency graph. - + The `--select` flag accepts one or more arguments. Each argument can be one of: @@ -68,7 +68,7 @@ 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 following characters: From 3a0d77cc2dd9ec76a54cc3a249009c8dba8f162c Mon Sep 17 00:00:00 2001 From: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:45:55 -0500 Subject: [PATCH 4/6] Update website/docs/reference/node-selection/syntax.md Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> --- website/docs/reference/node-selection/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/reference/node-selection/syntax.md b/website/docs/reference/node-selection/syntax.md index 31e4f878ff3..d7d2136b325 100644 --- a/website/docs/reference/node-selection/syntax.md +++ b/website/docs/reference/node-selection/syntax.md @@ -45,7 +45,7 @@ By default, `dbt run` will execute _all_ of the models in the dependency graph. - + The `--select` flag accepts one or more arguments. Each argument can be one of: From 706dbb021e9335e0bbc7104d2ba5b7a624d102d4 Mon Sep 17 00:00:00 2001 From: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:46:09 -0500 Subject: [PATCH 5/6] Update website/docs/reference/node-selection/syntax.md Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> --- website/docs/reference/node-selection/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/reference/node-selection/syntax.md b/website/docs/reference/node-selection/syntax.md index d7d2136b325..969db486c0e 100644 --- a/website/docs/reference/node-selection/syntax.md +++ b/website/docs/reference/node-selection/syntax.md @@ -68,7 +68,7 @@ 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 following characters: From a080863bb7bbe1b5695947be4aea5933bb0403d1 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Tue, 12 Dec 2023 06:55:34 -0500 Subject: [PATCH 6/6] add more node operator examples --- website/docs/reference/node-selection/syntax.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/website/docs/reference/node-selection/syntax.md b/website/docs/reference/node-selection/syntax.md index 969db486c0e..22946903b7d 100644 --- a/website/docs/reference/node-selection/syntax.md +++ b/website/docs/reference/node-selection/syntax.md @@ -43,7 +43,6 @@ Select resources to build (run, test, seed, snapshot) or check freshness: `--sel 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`. - @@ -81,7 +80,13 @@ 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.*"