Schedule a job
In this part of the guide, you will learn how to schedule a job to be run in your production environment. Scheduling a job is sometimes called deploying a project.
As the jaffle_shop
business gains more customers, and those customers create more orders, you will see more records added to your source data. Because you materialized the customers
model as a table, you'll need to periodically rebuild your table to ensure that the data stays up-to-date. This update will happen when you run a job.
Commit your changesβ
Now that you've built your customer model, you need to commit the changes you made to the project so that the repository has your latest code.
- Click Commit and add a message. For example, "Add customers model, tests, docs."
- Click merge to main To add these changes to the main branch on your repo.
Create a deployment environmentβ
- In the upper left, select Deploy, then click Environments.
- Click Create Environment.
- Name your deployment environment. For example, "Production."
- Add a target dataset, for example, "Analytics." dbt will build into this dataset. For some warehouses this will be named "schema."
- Click Save.
Create and run a jobβ
Jobs are a set of dbt commands that you want to run on a schedule. For example, dbt run
and dbt test
.
- After creating your deployment environment, you should be directed to the page for new environment. If not, select Deploy in the upper left, then click Jobs.
- Click Create one and provide a name, for example "Production run", and link to the Environment you just created.
- Scroll down to "Execution Settings" and select Generate docs on run.
- Under "Commands," add these commands as part of your job if you don't see them:
dbt run
dbt test
- For this exercise, do NOT set a schedule for your project to run -- while your organization's project should run regularly, there's no need to run this project on a schedule.
- Select Save, then click Run now to run your job.
- Click the run and watch its progress under "Run history."
- Once the run is complete, click View Documentation to see the docs for your project.
Congratulations π! You've just deployed your first dbt project!
FAQsβ
Next stepsβ
Congratulations! Now that you've got a working dbt project, you can read about dbt best practices.
You can improve your dbt skills with these fun exercises:
- Turn your raw data references (for example, turn
`dbt-tutorial`.jaffle_shop.orders
) into sources. - Build a new models for
orders
, that uses thepayments
table to calculate the total order amount. - Reorganize your project into how we structure dbt projects.
- If you want a more in-depth learning experience, we recommend taking the dbt Fundamentals on our dbt Learn online courses site.
Here are some ways to learn more essential dbt skills:
- Learn how to use Jinja in your project by reading the Jinja tutorial.
- Learn how to connect to dbt Core using the CLI.
- Refactor legacy SQL to dbt SQL.