You are currently viewing dbt ( data build tool ) Cheat Sheet

dbt ( data build tool ) Cheat Sheet

Main Commands

dbt init

Bash
# Initializes a new dbt project
dbt init

dbt build

Bash
# Builds and tests selected resources (models, seeds, snapshots, tests)
dbt build

dbt clean

Bash
# Deletes artifacts in the dbt project
# Compiles (does not run) models in a project
# Debugs dbt connections and projects
# Downloads dependencies for a project
dbt clean

dbt compile

Bash
# Compiles models in a project
dbt compile

dbt debug

Bash
# Debugs dbt connections and projects
dbt debug

dbt deps

Bash
# Downloads dependencies for a project
dbt deps

dbt docs

Bash
# Generates documentation for a project
dbt docs

dbt list

Bash
# Lists resources defined in a dbt project
dbt list

dbt parse

Bash
# Parses a project and writes detailed timing info
dbt parse

dbt run

Bash
# Runs the models in a project
# Flags: --full-refresh, --fail-fast, --threads
dbt run

dbt seed

Bash
# Loads CSV files into the database
dbt seed

dbt snapshot

Bash
# Executes "snapshot" jobs defined in a project
dbt snapshot

dbt source

Bash
# Provides tools for working with source data
dbt source

dbt test

Bash
# Executes tests defined in a project
dbt test

dbt rpc

Bash
# Runs an RPC server for client queries
# dbt run-operation - Runs arbitrary maintenance SQL against the database
dbt rpc

dbt serve

Bash
# Starts a webserver to serve documentation locally
dbt serve

Global CLI Flags

–version

Bash
dbt --version #Returns information about the installed dbt version

–record-timing-info

Bash
dbt --record-timing-info #Saves performance profiling information to a file

Syntax Overview

Node Selection

Bash
--select (-s), --exclude, --selector

Methods

Bash
tag, source, path, package, config, test_type, test_name, state, exposure, metric, result

Graph Operators

Bash
dbt run --select my_model+, $ dbt run --select +my_model+ # Plus Operator (+)
Bash
dbt run --select my_model+1, $ dbt run --select 2+my_model # N-plus Operator

Set Operators

Bash
dbt run --select +snowplow_sessions +fct_orders # Unions (space-delineated)

dbt run --select +snowplow_sessions,+fct_orders # Intersections (comma-separated)

At Operator (@)

Bash
dbt run --models @my_model # At Operator (@)

Star Operator (*)

Bash
dbt run --select finance.base.* # Star Operator (*)

Other Flags
–help

Bash
dbt --help. # Shows available commands and arguments

–vars

Bash
dbt --vars # Supplies variables to the project

Examples

Exclude Models

Bash
dbt run --select my_package.*+--exclude my_package.a_big_model+

Graph Operators

Bash
#Plus Operator
dbt run --select my_model+
dbt run --select +my_model+
dbt run --select +my_model+


#N-plus Operator
dbt run --select my_model+1
dbt run --select 2+my_model

Set Operators

Bash
#Unions (space-delineated)
dbt run --select +snowplow_sessions +fct_orders

#Intersections (comma-separated)
dbt run --select +snowplow_sessions,+fct_orders

dbt run --select marts.finance,tag:nightly
dbt test --select +fct_orders,test_type:generic


dbt run --select +snowplow_sessions,+fct_orders

Common Ancestors

Bash
dbt run --select +snowplow_sessions,+fct_orders

dbt run --select 3+my_model+4

dbt run --select my_model+ $ dbt run --select +my_model $ dbt run --select +my_model+

dbt run --select my_model+1 $ dbt run --select 2+my_model

dbt run --select 3+my_model+4

dbt run --select +snowplow_sessions,+fct_orders

dbt run --select +snowplow_sessions,+fct_orders

dbt run --select marts.finance,tag:nightly
dbt test --select +fct_orders,test_type:generic

dbt run --select +snowplow_sessions,+fct_orders

dbt run --select +snowplow_sessions,+fct_orders

dbt run --select marts.finance,tag:nightly
dbt test --select +fct_orders,test_type:generic

Table Of Commands

CommandDescription
dbt initInitializes a new dbt project
dbt buildBuilds and tests selected resources (models, seeds, snapshots, tests)
dbt cleanDeletes artifacts in the dbt project
dbt compileCompiles models in a project
dbt debugDebugs dbt connections and projects
dbt depsDownloads dependencies for a project
dbt docsGenerates documentation for a project
dbt listLists resources defined in a dbt project
dbt parseParses a project and writes detailed timing info
dbt runRuns the models in a project
dbt seedLoads CSV files into the database
dbt snapshotExecutes “snapshot” jobs defined in a project
dbt sourceProvides tools for working with source data
dbt testExecutes tests defined in a project
dbt rpcRuns an RPC server for client queries
dbt serveStarts a webserver to serve documentation locally
–versionReturns information about the installed dbt version
–record-timing-infoSaves performance profiling information to a file
–select (-s), –exclude, –selectorNode selection methods
–helpShows available commands and arguments
–varsSupplies variables to the project
–select my_model+, $ dbt run –select +my_model+Graph Operators – Plus Operator (+)
–select my_model+1, $ dbt run –select 2+my_modelGraph Operators – N-plus Operator
–select +snowplow_sessions +fct_ordersSet Operators – Unions (space-delineated)
–select +snowplow_sessions,+fct_ordersSet Operators – Intersections (comma-separated)
–models @my_modelAt Operator (@)
–select finance.base.*Star Operator (*)
dbt Cheat Sheet

Leave a Reply