Exercise#
Load data:
Jaffle Shop data : jaffle_shop data are already loaded in our postgres database:
orders,customersandpayments, so there is no action needed.Google Analytics data : traffic data are located in
ga_traffic.csvfile in seeds folder.Add this code snippet into
dbt_project.ymlfile at the end. This will createdbt_seedsschema inside your database once you rundbt seedcommand.seeds: +schema: seeds
Run
dbt seed --select ga_trafficcommand in dbt docker container which will load these .csv files into our database. You can double check by looking intodbt_seedsschema in DB Adminer.

Create source files: create a source file
_src_[sourcename].ymlfor each data source: jaffle_shop and google_analytics in their folders.Configure source files: edit both
_src_[sourcename].ymlfiles according to the example.Add tests: Define
uniquetest foridcolumn in each jaffle_shop table anddatecolumn in ga_traffic table.Test the solution: Test the uniqueness by running
dbt testcommand in dbt container.
Solution#
_src_jaffle_shop.yml
version: 2
sources:
- name: jaffle_shop
schema: raw
tables:
- name: orders
columns:
- name: id
tests:
- unique
- name: customers
columns: id
- name:
tests:
- unique
- name: payments
columns:
- name: id
tests:
- unique
_src_google_analytics.yml
version: 2
sources:
- name: google_analytics
schema: dbt_seeds
tables:
- name: ga_traffic
columns:
- name: date
tests:
- unique