ls (list)
Overview
The dbt ls
command lists resources in your dbt project. It accepts selector arguments that are similar to those provided in dbt run. dbt list
is an alias for dbt ls
.
Usage
dbt ls[--resource-type {source,analysis,model,snapshot,test,seed,exposure,default,all}][--select SELECTION_ARG [SELECTION_ARG ...]][--models SELECTOR [SELECTOR ...]][--exclude SELECTOR [SELECTOR ...]][--selector YML_SELECTOR_NAME [YML_SELECTOR_NAME ...]][--output {json,name,path,selector}][--output-keys KEY_NAME [KEY_NAME]]
See resource selection syntax for more information on how to select resources in dbt
Arguments:
--resource-type
: This flag limits the "resource types" that dbt will return in thedbt ls
command. By default, the following resources are included in the results ofdbt ls
: models, snapshots, seeds, tests, and sources.--select
: This flag specifies one or more selection-type arguments used to filter the nodes returned by thedbt ls
command--models
: Like the--select
flag, this flag is used to select nodes. It implies--resource-type=model
, and will only return models in the results of thedbt ls
command. Supported for backwards compatibility only.--exclude
: Specify selectors that should be excluded from the list of returned nodes.--selector
: This flag specifies one or more named selectors, defined in aselectors.yml
file.--output
: This flag controls the format of output from thedbt ls
command.--output-keys
: If--output json
, this flag controls which node properties are included in the output.
Note that the dbt ls
command does not include models which are disabled or schema tests which depend on models which are disabled. All returned resources will have a config.enabled
value of true
.
Example usage
Listing models by package
$ dbt ls --select snowplow.*snowplow.snowplow_base_eventssnowplow.snowplow_base_web_page_contextsnowplow.snowplow_id_mapsnowplow.snowplow_page_viewssnowplow.snowplow_sessions...
Listing tests by tag name
$ dbt ls --select tag:nightly --resource-type testmy_project.schema_test.not_null_orders_order_idmy_project.schema_test.unique_orders_order_idmy_project.schema_test.not_null_products_product_idmy_project.schema_test.unique_products_product_id...
Listing schema tests of incremental models
$ dbt ls --select config.materialized:incremental,test_type:schemamodel.my_project.logs_parsedmodel.my_project.events_categorized
Listing JSON output
$ dbt ls --select snowplow.* --output json{"name": "snowplow_events", "resource_type": "model", "package_name": "snowplow", ...}{"name": "snowplow_page_views", "resource_type": "model", "package_name": "snowplow", ...}...
Listing JSON output with custom keys
$ dbt ls --select snowplow.* --output json --output-keys name description{"name": "snowplow_events", "description": "This is a pretty cool model", ...}{"name": "snowplow_page_views", "description": "This model is even cooler", ...}...
Listing file paths
dbt ls --select snowplow.* --output pathmodels/base/snowplow_base_events.sqlmodels/base/snowplow_base_web_page_context.sqlmodels/identification/snowplow_id_map.sql...