One of the key features of DBT is its ability to create “clean” target tables, which are optimized for querying and analysis. Optionally specify a custom list of directories to be removed by the dbt clean command. You can remove packages and compiled files as part of dbt clean
A clean target table is a table that has been transformed and loaded from source data in a way that makes it easy to query and analyze. The process of creating a clean target table typically involves a number of steps, such as:
- Extracting data from source systems
- Transforming the data (e.g., cleaning, normalizing, and aggregating)
- Loading the data into a target table
The dbt clean-targets
command is used to perform the above steps. It loads the source data, applies any necessary transformations, and then loads the transformed data into a target table.
Include the value of your packages-install-path configuration in your clean-targets configuration to remove both packages and compiled files.
In dbt_project.yml
clean-targets:
- target
- dbt_packages
Remove logs when running dbt clean
clean-targets: [target, dbt_packages, logs]
For example, let’s say you have a source table called raw_orders
that contains data on customer orders, and you want to create a clean target table called orders
that is optimized for querying and analysis. You can create a clean_orders
model in dbt
by using the following command:
dbt clean-targets
This will create a clean target table orders
in the data warehouse and loaded with the cleaned data from raw_orders
.
It’s also possible to use dbt
to incrementally update the clean target table. For example, you can use dbt run --target clean
to only run the models that are needed to update the clean target table with new data.
dbt clean-targets
command is a powerful tool for creating clean target tables, but it does require some setup and configuration. You’ll need to define the source tables, the transformations to apply, and the target table schema in dbt
models. Once you’ve done that, you can use the dbt clean-targets
command to easily create and update your clean target tables.
In summary, DBT’s clean-targets
command is used to create a clean target table, which is optimized for querying and analysis. It loads source data, applies any necessary transformations and loads the transformed data into a target table. It is a powerful tool for ETL process and data warehousing but requires some setup and configuration.
Get more useful articles on dbt