Course Overview
Introduction to dbt

Using The dbt Command Line Interface

Lesson #5

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.

Next Lesson:
07

Using The dbt Command Line Interface

In this lesson we will use the dbt Command Line Interface to create and configure our first dbt project.

0h 15m




Work With The Experts In Real-Time Analytics & AI

we help enterprise organisations deploy powerful real-time Data, Analytics and AI solutions based on ClickHouse, the worlds fastest open-source database.

Join our mailing list for regular insights:

We help enterprise organisations deploy advanced data, analytics and AI enabled systems based on modern cloud-native technology.

© 2024 Ensemble. All Rights Reserved.