0
0
dbtdata~15 mins

Version pinning and updates in dbt - Mini Project: Build & Apply

Choose your learning style9 modes available
Version pinning and updates
📖 Scenario: You are working on a data project using dbt. To keep your project stable, you want to pin the dbt version your project uses. Later, you will learn how to update this version safely.
🎯 Goal: Learn how to pin a specific dbt version in your packages.yml file and update it when needed.
📋 What You'll Learn
Create a packages.yml file with a pinned dbt version
Add a variable to hold the new version number
Update the pinned version using the variable
Print the updated packages.yml content
💡 Why This Matters
🌍 Real World
In real data projects, pinning dbt versions helps keep your transformations stable and reproducible.
💼 Career
Data engineers and analysts often manage dbt projects and need to control package versions to avoid unexpected errors.
Progress0 / 4 steps
1
Create the initial packages.yml with pinned dbt version
Create a string variable called packages_yml that contains the exact text:
packages: - package: dbt-labs/dbt_utils version: 0.8.0
dbt
Need a hint?

Use triple quotes or escaped newlines to create the multi-line string exactly as shown.

2
Add a variable for the new dbt version
Create a variable called new_version and set it to the string '0.9.1'.
dbt
Need a hint?

Just assign the string '0.9.1' to the variable new_version.

3
Update the pinned version in packages_yml using new_version
Replace the version number 0.8.0 in packages_yml with the value of new_version using the replace method. Assign the result back to packages_yml.
dbt
Need a hint?

Use the string method replace to swap the old version with the new one.

4
Print the updated packages_yml content
Write a print statement to display the updated packages_yml string.
dbt
Need a hint?

Use print(packages_yml) to show the updated content.