Code Monkey home page Code Monkey logo

jaffle_shop's Introduction

Containerised Jaffle Shop dbt Project

This is a containerised version of the popular Jaffle Shop dbt project published by dbt Labs. You can use this project to populate and run Jaffle Shop in a Postgres instance.

Running the project with Docker

You'll first need to build and run the services via Docker (as defined in docker-compose.yml):

$ docker-compose build
$ docker-compose up

The commands above will run a Postgres instance and then build the dbt resources of Jaffle Shop as specified in the repository. These containers will remain up and running so that you can:

  • Query the Postgres database and the tables created out of dbt models
  • Run further dbt commands via dbt CLI

Building additional or modified data models

Once the containers are up and running, you can still make any modifications in the existing dbt project and re-run any command to serve the purpose of the modifications.

In order to build your data models, you first need to access the container.

To do so, we infer the container id for dbt running container:

docker ps

Then enter the running container:

docker exec -it <container-id> /bin/bash

And finally:

# Install dbt deps (might not required as long as you have no -or empty- `dbt_packages.yml` file)
dbt deps

# Build seeds
dbt seeds --profiles-dir profiles

# Build data models
dbt run --profiles-dir profiles

# Build snapshots
dbt snapshot --profiles-dir profiles

# Run tests
dbt test --profiles-dir profiles

Alternatively, you can run everything in just a single command:

dbt build --profiles-dir profiles

Querying Jaffle Shop data models on Postgres

In order to query and verify the seeds, models and snapshots created in the dummy dbt project, simply follow the steps below.

Find the container id of the postgres service:

docker ps 

Then run

docker exec -it <container-id> /bin/bash

We will then use psql, a terminal-based interface for PostgreSQL that allows us to query the database:

psql -U postgres

You can list tables and views as shown below:

postgres=# \dt
             List of relations
 Schema |     Name      | Type  |  Owner   
--------+---------------+-------+----------
 public | customers     | table | postgres
 public | orders        | table | postgres
 public | raw_customers | table | postgres
 public | raw_orders    | table | postgres
 public | raw_payments  | table | postgres
(5 rows)

postgres=# \dv
            List of relations
 Schema |     Name      | Type |  Owner   
--------+---------------+------+----------
 public | stg_customers | view | postgres
 public | stg_orders    | view | postgres
 public | stg_payments  | view | postgres
(3 rows)

Now you can query the tables constructed form the seeds, models and snapshots defined in the dbt project:

SELEC * FROM <table_or_view_name>;

jaffle_shop's People

Contributors

gmyrianthous avatar

Stargazers

 avatar Yuho Jeong avatar Michael Ladd avatar  avatar Renan Hilbert avatar

Watchers

 avatar

jaffle_shop's Issues

Improve Readme.md

At the final section of the readme.md, the query says: "SELEC". this part of the query would be "SELECT"

Improve "dbt seeds"

This command "dbt seeds --profiles-dir profiles" don't work, the code works with "dbt seed --profiles-dir profiles"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.