In this lesson we will:
- Begin to use the dbt binary for some simple operations outside of the context of a specific project.
The dbt Executable
We can begin by simply running the dbt command to check for a correct installation:
dbt
Amongst the output you will see that we have a number of sub commands which perform different activities such as initialising projects, executing your dbt models, loading seed data and executing tests.
Available sub-commands:
{docs,source,init,clean,debug,deps,list,ls,build,snapshot,run,compile,parse,test,seed,run-operation}
docs Generate or serve the documentation website for your project.
source Manage your project's sources
init Initialize a new dbt project.
clean Delete all folders in the clean-targets list (usually the dbt_packages and target directories.)
debug Show some helpful information about dbt for debugging. Not to be confused with the --debug option which increases verbosity.
deps Pull the most recent version of the dependencies listed in packages.yml
list (ls) List the resources in your project
build Run all Seeds, Models, Snapshots, and tests in DAG order
snapshot Execute snapshots defined in your project
run Compile SQL and execute against the current target database.
compile Generates executable SQL from source, model, test, and analysis files. Compiled SQL files are written to the target/ directory.
parse Parses the project and provides information on performance
test Runs tests on data in deployed models. Run this after `dbt run`
seed Load data from csv files into your data warehouse.
run-operation Run the named macro with any supplied arguments.
Command Line Help
For each of these sub commands, you can use the help flag to better understand the required parameters for each one:
dbt build --help
dbt test --help
dbt source --help
dbt compile --help
Though you will quickly get used to the most common operations for building, testing and running your models, this online help is useful whilst learning dbt and moving into new areas.
Versioning
The version flag shows the installed version of dbt and if you are running on an out of date version. It also shows the status of the individual warehouse adapters.
dbt --version
Outputs:
Core:
- installed: 1.4.1
- latest: 1.4.1 - Up to date!
Plugins:
- postgres: 1.4.1 - Up to date!
Ordinarily these versions will stay in line when you upgrade dbt, but there may be situation where we you need to remain on a certain version of a warehouse adapter but move forward with the dbt version as your codebase matures. For now, it is worth being aware that there is both a dbt version and a warehouse adapter version.
Because dbt is evolving very quickly, it is worth attempting to stay on the latest version where possible to have the most stable experience and avoid difficult upgrades later on.
Creating A Project
Most of the other dbt command line interactions require a project. In the next lab we will create a project then continue with our exploration of the dbt command line options.