This is a simple, loveable, and complete SQLMesh demo project with the goal of running multiple, realistic scenarios very fast.
This repo is going to try something a bit novel compared to your standard demo projects. I'll take you through different stories that illustrate the data engineering workflow. It'll engage your inner dialogue along with look and feel of the development experience. The hope is for you to better internalize and translate these stories to your own reality. Don't worry, these stories won't be too long-winded!
This is intentionally similar to what people may have experienced when I created this github repo at dbt Labs: here
What you'll be using:
- SQLMesh: transformation framework
- BigQuery: data warehouse to run transforms against
- DuckDB: local development testing
- Postgres: Store SQLMesh metadata
- SQLGlot: Python macros that compile to SQL
- pytest: test Python macros
Setup your virtual environment for SQLMesh:
git clone https://github.com/sungchun12/sqlmesh-demos.git # clone the repo
cd sqlmesh-demos # go to the root directory
python -m venv venv # create virtual environment
source venv/bin/activate # activate it
pip install -r requirements.txt # install dependencies
source venv/bin/activate # reactivate virtual environment
Setup your BigQuery Service Account:
- Create a service account following these instructions: here
- Add permissions:
BigQuery Data Editor
,BigQuery User
- Download the service account json file
- Copy the contents of the service account file to your clipboard
- Export the credentials as an environment variable in your terminal:
export GOOGLE_CREDENTIALS=<your-service-account-key-contents>
Setup your Postgres Database:
- Sign up for a free Neon account: here
- Create a new database named:
sqlmesh_state_demo
- Export your environment variables based on the newly created database connection string
# examples based on the image above
export SQLMESH_STATE_HOST=ep-purple-heart-a6mqlep8.us-west-2.aws.neon.tech
export SQLMESH_STATE_USERNAME=<your-neon-username>
export SQLMESH_STATE_PASSWORD=<your-password-blurred-in-the-image>
Verify SQLMesh can connect to BigQuery and Postgres:
sqlmesh info # print info about a SQLMesh project
# expected output
Models: 15
Macros: 1
Data warehouse connection succeeded
State backend connection succeeded
Test connection succeeded
How do I run SQLMesh as fast as possible and get the general look and feel?
Run this command and watch the demo video!
sqlmesh plan # follow the instructions in the CLI prompt
TODO: add video
How do I go about making a big breaking change to the logic of a core sql model?
TODO
Portions of this project are modifications based on work created and shared by dbt Labs and used according to terms described in the Apache License, Version 2.0. For the original work and its license, see: here