Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Node selection syntax

dbt · Workflow, CI & Performance

Node selection syntax

Mediumdbt-49
selectorsclidagworkflow

Question

Explain dbt's selection syntax: +model, model+, @model, tag:, path:.

Solution

dbt selection syntax uses graph operators and property qualifiers to target specific subsets of a project Directed Acyclic Graph. Operators like plus and at control directional dependency traversal, while prefixes like tag and path select models based on metadata and directory structure.

Directional graph traversal

The plus operator traverses dependencies along the graph:

  • model+ selects the specified model and all of its downstream children. For example, stg_orders+ builds stg_orders and every mart or intermediate model that depends on it.
  • +model selects the model and all of its upstream parents. Running +fct_orders builds every staging and intermediate model needed to produce fct_orders.
  • Specifying a number sets the traversal depth. 1+model selects only direct parents one hop away, while model+2 selects the model and children up to two hops downstream.

These directional controls let you test isolated sections of a pipeline.

The at symbol and boundary selection

The at operator provides boundary-aware selection. Running dbt run with @fct_orders selects fct_orders, all of its downstream descendants, and all upstream ancestors of those descendants.

This operator is useful when testing modifications in an isolated development schema:

  • If a downstream mart model depends on both fct_orders and dim_customers, building downstream models without building dim_customers causes broken references.
  • The at operator includes dim_customers automatically, guaranteeing that downstream dependencies can build from scratch without errors.

This avoids manual tracking of sibling dependencies.

Attribute selectors and saved sets

dbt supports selecting models by file location, configuration tags, and data sources:

  • path:models/marts/finance selects all models residing in that directory.
  • tag:nightly selects models marked with that tag in YAML or config blocks.
  • source:stripe+ selects the Stripe source and all downstream models reading from it.
  • exclude removes nodes from the selection, such as dbt run with marts+ and exclude tag:heavy.

For complex recurring orchestrations, you can save selection logic in a selectors.yml file, giving developers and orchestrators a single named selector to invoke.

PreviousNext