Methods
Selector methods allow you to filter resources based on specific properties using the method:value
syntax. While it's advisable to explicitly denote the method, you can omit it, and the default will be one of path
, file
, or fqn
.
Most selector methods below support unix-style wildcards:
Wildcard | Description | Example |
---|---|---|
* | 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 |
|
Below are examples of several popular selector methods:
"tag" Method
Use the tag:
method select models with a specified tag.
"source" Method
Use the source:
method to select models that reference a specified source.
"resource_type" method
Use the resource_type
method to select nodes of a specific type (ex. model
, test
, exposure
, etc.)
"path" method
Use path
method to select models/sources defined at or under a specific path.
"file" method
Use file
method to select a model by filename.
"fqn" method
Use 'fqn' to select nodes based off their "fully qualified name" (FQN). The default FQM format includes the dbt project name, subdirectories, and the file name
"package" method
Use package
method to select models defined within the root project or an installed dbt package.
"config" method
Use config
to select models that match a specified node config.
Note: config
method work for non-string values, such as: booleans, dictionary keys, values in arrays, etc.
Suppose you have a model with the following configurations:
You can use config
method to select the following:
"test_type" method
Use test_type
to select tests based on type (singular
or generic)
"test_name" method
Use test_name
method to select tests based on the name of the test defined.
"state" method
When using the "state" method in a Bolt schedule of type Deferred or Turbo-CI, you don't need to pass the --state path/to/project/artifacts
to your dbt command.
Paradime will point to the artifacts based on the Bolt schedule configurations:
Deferred schedule
Last run type
Note: State-based selection is a powerful and complex feature. Make sure to read about the known caveats and limitations of state comparison.
The state method selects nodes by comparing them against a previous version of the same project, represented by a manifest. The file path of the comparison manifest must be specified using the --state
flag or the DBT_STATE
environment variable.
state:new
: Indicates there is no node with the sameunique_id
in the comparison manifest.state:modified
: Includes all new nodes and any changes to existing nodes.
Because state comparison is complex, and everyone's project is different, dbt supports subselectors that include a subset of the full modified
criteria:
state:modified.body
: Changes to node body (e.g. model SQL, seed values)state:modified.configs
: Changes to any node configs, excludingdatabase
/schema
/alias
state:modified.relation
: Changes todatabase
/schema
/alias
(the database representation of this node), irrespective oftarget
values orgenerate_x_name
macrosstate:modified.persisted_descriptions
: Changes to relation- or column-leveldescription
, if and only ifpersist_docs
is enabled at each levelstate:modified.macros
: Changes to upstream macros (whether called directly or indirectly by another macro)state:modified.contract
: Changes to a model's contract, which currently include thename
anddata_type
ofcolumns
. Removing or changing the type of an existing column is considered a breaking change, and will raise an error.
Remember that state:modified
includes all of the criteria above, as well as some extra resource-specific criteria, such as modifying a source's freshness
or quoting
rules or an exposure's maturity
property.
There are two additional state
selectors that complement state:new
and state:modified
by representing the inverse of those functions:
state:old
— A node with the sameunique_id
exists in the comparison manifeststate:unmodified
— All existing nodes with no changes
These selectors can help you shorten run times by excluding unchanged nodes. Currently, no subselectors are available at this time, but that might change as use cases evolve.
"exposure" method
Use exposure
method to select the parent resources of an exposure.
"metric" method
Use metric
method to select parent resources of a metric.
"results" method
When using the "results" method in a Bolt schedule of type Deferred or Turbo-CI, you don't need to pass the --state path/to/project/artifacts
to your dbt command.
Paradime will point to the artifacts based on the Bolt schedule configurations:
Deferred schedule
Last run type
Use result
method to select resources based on their results status from a previous execution.
Note: This method only works if a dbt command (ex. seed
, test
, run
, build
.) was performed prior.
"source_status" method
When using the "source_status" method in a Bolt schedule of type Deferred or Turbo-CI, you don't need to pass the --state path/to/project/artifacts
to your dbt command.
Paradime will point to the artifacts based on the Bolt schedule configurations:
Deferred schedule
Last run type
Another element of job state is the source_status
from a prior dbt invocation. For instance, after running dbt source freshness
, dbt generates the sources.json
artifact, which includes execution times and max_loaded_at
dates for dbt sources.
The following dbt commands produce sources.json
artifacts whose results can be referenced in subsequent dbt invocations:
dbt source freshness
After running one of the above commands, you can reference the source freshness results by adding a selector to a subsequent command as follows:
"group" method
Use group
method to select models defined within a specified group.
"access" Method
Use access
method to select models based on their access property.
"version" Method
Use version
to select versioned models based on the following:
Version Identifier: A specific version label or number (
old
,prerelease
,latest
)Latest Version: The most recent version of a model.
"semantic_model" Method
Use semantic_model
method to selects semantic models.
"saved_query" method
Use saved_query
method to selects saved queries.
"unit_test" method
Use unit_test
method to selects dbt™️ unit tests.
Last updated