Skip to content

Commit bc1015e

Browse files
authored
Merge pull request #41 from DataRecce/document/getting-started-by-jaffle-shop
[Document] Add the Jaffle Shop example
2 parents 5325080 + 54e853d commit bc1015e

File tree

4 files changed

+105
-33
lines changed

4 files changed

+105
-33
lines changed

README.md

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,55 +36,34 @@ jaffle_shop:
3636

3737
## Getting Started
3838

39+
[5 minutes walkthrough by jaffle shop example](./docs/get-started-jaffle-shop.md)
40+
3941
1. Installation
4042

4143
```
4244
pip install recce
4345
```
4446

45-
1. Recce use [dbt artifacts](https://docs.getdbt.com/reference/artifacts/dbt-artifacts) to interact with your dbt project. You need to prepare the artifacts for the base environment.
46-
47-
```shell
48-
# transform the data to data warehouse
49-
dbt run --target prod
50-
51-
# generate the catalog.json
52-
dbt docs generate --target prod
53-
```
54-
55-
The artifacts are generated within the `target/` directory. Copy these artifacts into the `target-base/` directory as the base state to diff.
56-
47+
1. Go to your dbt project
5748
```
58-
mkdir -p target-base/
59-
cp -R target/ target-base/
49+
cd your-dbt-project/
6050
```
51+
1. **Prepare base artifacts**: DBT generates [artifacts](https://docs.getdbt.com/reference/artifacts/dbt-artifacts) when every invocation. You can find these files in the `target/` folder.
6152

62-
1. Develop your awesome features
53+
| artifacts | dbt command |
54+
| ----------------------- | -------------------------- |
55+
| manifest.json | `dbt run`, `dbt build`, .. |
56+
| catalog.json (optional) | `dbt docs generate` |
6357

64-
```shell
65-
# transform the data to data warehouse
66-
dbt run
58+
Copy the artifacts for base environment to `target-base/`
6759

68-
# generate the catalog.json
69-
dbt docs generate
70-
```
71-
72-
1. Run the recce server
60+
1. Run the recce server.
7361

7462
```
7563
recce server
7664
```
7765

78-
and open the url link
79-
80-
1. Check the lineage diff to see the modified node. Click one node to see the schema difference.
81-
1. Switch to **query** tab, Write and run a query diff. It would query on the both side and diff the query results.
82-
83-
```jinja
84-
select * from {{ ref("mymodel") }}
85-
```
86-
87-
where `ref` is a Jinja function to reference a model name.
66+
Recce would diff environments between `target/` and `target-base/`
8867

8968
## Query Diff
9069

docs/assets/jaffle_shop_lineage.png

222 KB
Loading

docs/assets/jaffle_shop_query.png

243 KB
Loading

docs/get-started-jaffle-shop.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## Getting Started by Jaffle Shop
2+
3+
**Jaffle Shop** is an example project officially provided by dbt-labs. This document uses [jaffle_shop_duckdb](https://github.com/dbt-labs/jaffle_shop_duckdb) to enable you to start using **recce** locally from scratch within five minutes.
4+
5+
1. Clone the “Jaffle Shop” dbt data project
6+
7+
```bash
8+
git clone git@github.com:dbt-labs/jaffle_shop_duckdb.git
9+
cd jaffle_shop_duckdb
10+
```
11+
12+
1. Prepare virtual env
13+
```bash
14+
python -m venv venv
15+
source venv/bin/activate
16+
```
17+
1. Installation
18+
```bash
19+
pip install -r requirements.txt
20+
pip install recce
21+
```
22+
1. Provide additional environment to compare. Edit `./profiles.yml` to add one more target.
23+
24+
```diff
25+
jaffle_shop:
26+
target: dev
27+
outputs:
28+
dev:
29+
type: duckdb
30+
path: 'jaffle_shop.duckdb'
31+
threads: 24
32+
+ prod:
33+
+ type: duckdb
34+
+ path: 'jaffle_shop.duckdb'
35+
+ schema: prod
36+
+ threads: 24
37+
```
38+
39+
1. Prepare production environment
40+
41+
```bash
42+
dbt build --target prod
43+
dbt docs generate --target prod
44+
```
45+
46+
and copy the artifacts to `./target-base/`
47+
48+
```bash
49+
cp -R target/ target-base/
50+
```
51+
52+
1. Prepare development environment. First, edit an existing model `./models/staging/stg_payments.sql`.
53+
54+
```diff
55+
...
56+
57+
renamed as (
58+
payment_method,
59+
60+
- -- `amount` is currently stored in cents, so we convert it to dollars
61+
- amount / 100 as amount
62+
+ amount
63+
64+
from source
65+
)
66+
```
67+
68+
run on development environment.
69+
70+
```bash
71+
dbt build
72+
dbt docs generate
73+
```
74+
75+
1. Run the recce server
76+
77+
```bash
78+
recce server
79+
```
80+
81+
Open the link http://0.0.0.0:8000, you can see the lineage diff
82+
83+
![](assets/jaffle_shop_lineage.png)
84+
85+
1. Switch to the **Query** tab, run this query
86+
87+
```sql
88+
select * from {{ ref("orders") }} order by 1
89+
```
90+
91+
Click on the 🔑 icon next to the `order_id` column to compare records that are uniquely identified by their `order_id`.
92+
93+
![](assets/jaffle_shop_query.png)

0 commit comments

Comments
 (0)