Selector Methods
Last updated
Last updated
Selector methods in dbt allow you to filter resources based on specific properties using the method:value
syntax. This gives you the power to target exactly what you need during your data transformations.
Most selector methods support Unix-style wildcards, which can help you target a broader set of resources:
*
: Matches any number of characters (including none)
?
: Matches any single character
[abc]
: Matches one character listed in the bracket
[a-z]
: Matches one character from the specified range in the bracket
For example:
Use tag:
to select models with a specific tag.
Use source:
to select models that reference a specified source.
Use resource_type:
to select nodes of a specific type (e.g., model, test, exposure).
Use path:
to select models/sources defined at or under a specific path.
Use file:
to select a model by filename.
Use fqn:
to select nodes based on their fully qualified name.
Use package:
to select models defined within the root project or an installed dbt package.
Use config:
to select models that match a specified node config.
Use test_type:
to select tests based on type (generic, singular, unit, data).
Use test_name:
to select tests based on the name of the test defined.
Use state:
to select nodes by comparing them against a previous version of the project.
Use exposure:
to select the parent resources of an exposure.
Use metric:
to select parent resources of a metric.
Use result:
to select resources based on their results status from a previous execution.
Use source_status:
to select based on the freshness of sources.
Use group:
to select models defined within a specified group.
Use access:
to select models based on their access property.
Use version:
to select versioned models.
Use semantic_model:
to select semantic models.
Use saved_query:
to select saved queries.
Use unit_test:
to select dbt unit tests.
Combine selectors for laser-focused selection:
Use graph operators like +
and @
for complex selections:
Exclude models using the --exclude
flag:
If you omit the method, dbt will default to one of path
, file
, or fqn
.
Remember, the more targeted your selector methods, the more precisely you can execute your dbt transformations.