This repository contains a complete dbt project built on Snowflake, designed to model and snapshot session-level user activity. It was created for an academic assignment following structured class instructions.
- ✅ Create a dbt project connected to Snowflake
- ✅ Set up input models using CTEs
- ✅ Build an output model:
session_summary - ✅ Implement snapshots for the output table
- ✅ Add schema-level tests on key fields
- ✅ Include all SQL and YAML files + screenshots in this repo
WITH base AS (
SELECT
userId,
sessionId,
channel
FROM {{ source('raw', 'user_session_channel') }}
)
SELECT * FROM base;WITH base AS (
SELECT
sessionId,
ts
FROM {{ source('raw', 'session_timestamp') }}
)
SELECT * FROM base;WITH user_sessions AS (
SELECT * FROM {{ ref('user_session_channel') }}
),
timestamps AS (
SELECT * FROM {{ ref('session_timestamp') }}
)
SELECT
u.userId,
u.sessionId,
u.channel,
t.ts
FROM user_sessions u
JOIN timestamps t
ON u.sessionId = t.sessionId;version: 2
models:
- name: session_summary
columns:
- name: sessionId
tests:
- unique
- not_null{% snapshot snapshot_session_summary %}
{{
config(
target_schema='snapshots',
unique_key='sessionId',
strategy='check',
check_cols=['userId', 'channel', 'ts']
)
}}
SELECT * FROM {{ ref('session_summary') }}
{% endsnapshot %}| 📌 Screenshot | Description |
|---|---|
dbt_model_1.png |
Input models: user_session_channel & session_timestamp |
dbt_model_2.png |
Output model: session_summary |
dbt_snapshot.png |
Snapshot for session_summary |
dbt_test_results.png |
dbt test run showing uniqueness and not_null tests |
✔ All screenshots available in the
/screenshotsfolder
dbt-coreSnowflake(target platform)YAMLfor model/test configuration- SQL CTEs for modeling logic
- Using dbt's modular SQL approach to build and test pipelines
- Applying snapshot logic to track dimension changes
- Writing schema-level tests for data integrity
- Creating source models and documenting metadata
Nakshatra Desai
Graduate Student – MS Data Analytics @ SJSU
📫 LinkedIn