dbt


dbt

Overview

The dbt tool is a powerful framework for data transformation in a warehouse. It allows you to model SQL queries, build snapshots, and run tests.

Key Commands

  • `dbt debug**: Inspect the project structure and database connections.

  • `dbt run**: Execute all models in the current project.

  • `dbt test —select example_model**: Run only the specified model’s tests.

  • **`dbt build —select example_model+****: Build the chosen model and its downstream dependencies.

  • **dbt build --exclude "tag:not_now"****: Build all models except those tagged with not_now`.

  • **dbt build --select "tag:one,tag:two"****: Build models that have both tags oneandtwo`.

  • **dbt build --select "tag:one tag:two"**: Build models having either oneortwo`.

Common Pitfalls

  1. Misusing the syntax for selecting tags; use a comma or separate tags in a single string.
  2. Inclusion of a —exclude option may cause unintended build failures.

Examples

# Inspect project
dbt debug

# Run all models
dbt run

# Test only example_model
dbt test --select example_model

# Build selected model and its downstream
dbt build --select example_model+

# Exclude tag:not_now
dbt build --exclude "tag:not_now"

# Select both tags
dbt build --select "tag:one,tag:two"

# Either tags
dbt build --select "tag:one tag:two"

See Also