To use this feature, make sure to first install the dbt™️-codegen package in your dbt™️ project.
View on GitHub
Generate base models
To generate base models, use thedbt-generator generate command. This is a wrapper around the codegen command that will generate the base models. This is especially useful when you have a lot of models, and you want to generate them all at once.
Example
source.yml file and generate the base models in the staging/source_name folder. If you have multiple sources defined in your yml file, use the --source-index flag to specify which source you want to generate base models for.
Transform base models using a custom YAML file
transforms.yml file that will be read in (the .yml file can be named anything). This file will contain the transforms that you want to apply to all the base models. You can just rename the fields in the base models or apply a custom SQL select to the transformed fields.
For the same source, you often have consistent naming conventions between tables. For example, the created_at and modified_at fields are often named the same for all tables. Changing all these fields to common values across different sources is a best practice. However, doing that for all the date columns in 10+ tables is a pain.
Transform base models using pre-built configs
Supported data warehouse:- BigQuery: bq_transform
- Snowflake: sf_transform
Example
.yml file when applied to all models in the staging/source_name folder will cast all ID field to INT64 and rename all the date columns to a value in the name key. For example, CREATED_TIME will be renamed to CREATED_AT and DATE_START will be renamed to START_AT. If no sql is provided, the package will just rename the field. If a sql is provided, the package will execute the SQL and rename the field using the name key.
staging/source_name folder using the transforms.yml file. You can also drop the metadata by setting the drop-metadata flag to true (dropping columns start with _). The --case-sensitive flag will determine if the transforms will use case-sensitive names or not.\