You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository demonstrates a **Lambda Architecture** using dbt. It shows how you can combine historical and near real-time data through separate layers.
4
+
5
+

6
+
7
+
## What’s Included
8
+
9
+
-**Prep Layer:**
10
+
Loads and prepares all raw data from the `purchases` seed. This layer supports querying all data from the raw seed.
11
+
12
+
-**Fact Layer Macro:**
13
+
A macro (`fact_purchases_sql`) that transforms the prep data and applies a date filter using the `lambda_filter_by_date` macro.
14
+
15
+
-**Fact Layer Model:**
16
+
A model that calls the fact layer macro to build an incremental fact table from the prep data.
17
+
18
+
-**OBT/Lambda View:**
19
+
A view that uses `lambda_union_by_date` to dynamically union historical fact data with new raw data based on the batch cycle date. It determines whether to pull data from the fact or raw layer.
20
+
21
+
## Steps to Run the Demo
22
+
23
+
1.**Seed the Data:**
24
+
Run the following command to load the raw seed data:
25
+
```bash
26
+
dbt seed
27
+
```
28
+
29
+
2.**Build the Models:**
30
+
Build all models by running:
31
+
```bash
32
+
dbt run
33
+
```
34
+
35
+
3.**Initial Check:**
36
+
- Query the **fact** model and the **OBT/lambda view**.
37
+
- You should see **20 records** in each.
38
+
39
+
4.**Simulate New Data:**
40
+
- Move the data from the backup seed into the raw seed file (this simulates new data arriving).
41
+
- Run the seed command again:
42
+
```bash
43
+
dbt seed
44
+
```
45
+
46
+
5. **Rebuild and Validate:**
47
+
Run:
48
+
```bash
49
+
dbt run
50
+
```
51
+
- Now, when you query the **fact** model, it should still show **20 records**.
52
+
- The **OBT/lambda view** will display **45 records**, with **25 new records** coming from the raw layer.
53
+
54
+
This demo shows how the Lambda Architecture in dbt can dynamically merge historical data with new incoming data at query time.
0 commit comments