Build and Test Models with New Source Data
This template creates an optimized schedule that executes dbt™ models only when necessary by comparing manifests between runs. It reduces unnecessary model runs by building only models with code changes or fresher source data, making it ideal for resource optimization and efficient production deployments.
Key Benefits
Run only modified models that have changed since the last successful execution
Execute models with fresher source data, avoiding unnecessary processing of static data
Automatically retry failed models from previous runs for quick production recovery
Prerequisites
Scheduler Environment is connected to your data warehouse provider.
An existing Bolt schedule that executed
dbt source freshness
for manifest comparison.The steps to create this schedule and generate the initial artifacts are covered in Part 1 and Part 2 below.
If you already have a Bolt schedule that has executed the
dbt source freshness
command, you can skip ahead to Part 3: Create "Build and Test Models with New Source Data" from Template.
How to Configure
Implementing the "Build and Test Models with New Source Data" schedule requires a multi-step setup process. Follow these instructions carefully to ensure a successful configuration.
Part 3: Create "Build and Test Models with New Source Data" from Template
Create the main Bolt schedule that will execute the dbt model builds and tests. It leverages the artifacts (manifests, run results, sources) generated in the previous prerequisite steps to enable the optimized model rebuilds.
From the Bolt home screen, select + New Schedule and then select the "Build and Test Models with New Source Data" template.
Schedule Type: Select Deferred, which enables manifest comparison between runs.
Name: Provide a relevant name (e.g. "Build and Test Models with New Source Data")
Description (Optional): Describe the purpose of this schedule (e.g. "Automatically build and test only models with fresher source data")
Deferred Schedule: Initially, select the existing "Source Freshness Check" schedule. This allows the first run to have manifest files (AKA artifacts) to compare against.
Last Run Type: Select Last Run to use the artifacts from the most recent execution.
Command Settings: Update the existing dbt commands:
Starting with the command dbt build --select source_status:fresher+
ensures the initial setup is successful in generating the necessary artifacts, before transitioning to the more comprehensive command in the later step.
Notification Settings (Optional): Configure success, failure, and SLA breach alerts via email, Slack, or MS Teams.
Click "Deploy" to save the new schedule.
Part 4: Generate Initial Artifacts for "Build and Test Models with New Source Data" Schedule
Execute an initial run of the "Build and Test Models with New Source Data" schedule. This generates the necessary manifest files (artifacts) that will be used for state comparison.
From the Bolt home screen, click on the newly created "Build and Test Models with New Source Data" schedule.
Click "Run" to execute an initial run and generate the manifest files (artifacts).
Verify the initial run was successful by checking the run history
Part 5: Transition to Self-Sustaining Schedule
Update the "Build and Test Models with New Source Data" schedule to be self-sustaining, allowing it to compare each subsequent run against its own previous successful execution. This makes the schedule more robust and efficient over time.
From the Bolt home screen, click on the "Build and Test Models with New Source Data" schedule.
Click "Edit" to modify the configuration.
Update the Deferred Schedule to "self" so the schedule can compare against its own previous successful run.
Command Settings: Reintroduce the full commands:
Reintroducing the full command allows the schedule to compare each run against its own previous successful execution, providing a comprehensive rebuild process. This addresses changes in source data and model code, while retrying failed models to keep the data pipeline up-to-date and healthy over time.
Click "Deploy" to save the changes.
This multi-step setup ensures the "Build and Test Models with New Source Data" schedule has the necessary artifacts and configuration to intelligently rebuild only the models with fresher source data or code changes, optimizing compute and improving deployment efficiency.
Last updated