Ismael Rodrigues
02/28/2024, 3:46 AMScout
02/28/2024, 3:46 AMsources.yaml
file per models folder in a dbt project. Typically, a dbt project has a single sources.yml
file within the models
directory, which is used to declare all sources for the project. This file contains the configurations for your sources, including descriptions, metadata, and tests. If you need to manage multiple sources or have a complex project structure, you might consider organizing your sources.yml
file with multiple source entries, each potentially corresponding to different databases, schemas, or logical groupings of tables. However, the standard practice with dbt is to consolidate source definitions into a single sources.yml
file for clarity and maintainability. For specific use cases or advanced configurations not covered in the documentation, it's recommended to refer to the official dbt documentation or seek guidance from the dbt community, as practices can vary depending on the version of dbt and the specifics of the project setup.Ismael Rodrigues
02/28/2024, 3:05 PMScout
02/28/2024, 3:05 PMdbt run
command with the --models
(or -m
for short) option followed by a directory path. This allows you to specify which models to run based on their location within your dbt project's models
directory. Here's how you can do it: bash dbt run --models path.to.models_folder.*
Replace path.to.models_folder
with the actual path to your folder within the models
directory. The *
at the end is a wildcard that tells dbt to run all models within that folder. For example, if you have a folder structure like this: models/ ├── marketing/ │ ├── email_campaigns.sql │ └── customer_segments.sql └── sales/ ├── sales_orders.sql └── sales_performance.sql
And you only want to build the models inside the marketing
folder, you would run: bash dbt run --models marketing.*
This command will build all models within the marketing
folder and any subdirectories inside it. Remember that dbt uses the folder structure to create a namespace for models, so the folder path in the command should match the namespace you want to target. If you have nested folders, you can specify the path to the desired level to target models within that specific subdirectory. For more advanced selection syntax, you can also use dbt's selection methods, such as +
, @
, or tag:
to further refine which models to run. Check the dbt documentation for more details on selection syntax.