Lab Steps

lock
Connecting to the dbt Web IDE
lock
Configuring a dbt Profile
lock
Defining dbt Sources
Need help? Contact our support team

Here you can find the instructions for this specific Lab Step.

If you are ready for a real environment experience please start the Lab. Keep in mind that you'll need to start from the first step.

Introduction

When you want to perform data modeling and transformations through dbt, you need to have some data to start from. dbt leverages the data you have in your database (possibly raw data) and uses it as a starting point. In dbt this data is referred as sources. Before starting any kind of transformation definition, you need to define the sources, so you will be able to leverage them.

In this lab step, you will define dbt sources and use the pre-loaded data in your lab environment as the sources.

 

Instructions

1. Create a new file named sources.yml under the ca_dbt_project/models folder.

alt

This file will contain the definition of the sources you want to use in your dbt project. Of course, if you had lot of models organized in different folders and subfolders, you could define more source files. Also, the sources.yml name is not mandatory. You can use any name you want, the important thing is that the YML definition inside follows the source definition described below.

 

2. Open the sources.yml file and enter the following YML snippet in order to define the sources the dbt project can access:

Copy code
version: 2
sources:
  - name: ca_dbt_project_sources>
    database: ca_dbt
    schema: public
    tables:
      - name: categories
      - name: customers
      - name: employees
      - name: order_details
      - name: products
      - name: shippers
      - name: suppliers
      - name: orders

The sources are pre-loaded in the lab environment you are currently using. They are sample tables following the relational model. The overview schema of their relations is the following:

alt

You just defined only one database and schema for your sources, but you can define as many sources as you want coming from different databases and schemas. For more information about dbt sources checkout the official dbt docs.

  

3. Save the content of the sources.yml file by pressing CTRL + S (Windows Users) or CMD + S (macOS Users).

 

Summary

In this lab step, you defined dbt sources. You also checked for the freshness of your sources.

Validation checks
1Checks
Defined the dbt Sources

Check whether the dbt sources have been defined.

Data build tool (dbt)