Something went wrong. Try again.
Learn DBT + BiqQuery
Something went wrong. Try again.
README.md
try-dbt-bq #
Learning dbt with BigQuery using public datasets.
Project Structure #
models/ecommerce/stg_users.sql - A staging view that:
- Pulls user data from BigQuery's public
thelook_ecommercedataset - Calculates
days_since_signupfor each user - Materializes as a view (fast, always fresh)
models/ecommerce/user_segments.sql - An analytics table that:
- References the staging model using
{{ ref('stg_users') }} - Segments users into: new, active, returning, veteran
- Groups ages into brackets for analysis
- Materializes as a table (slower to build, fast to query)
models/ecommerce/schema.yml - Documentation with:
- Column descriptions
- Data quality tests (uniqueness, not_null, accepted_values)
Key dbt Concepts #
-
Models = SELECT statements that become tables/views
-
Refs =
{{ ref('model_name') }}creates dependencies between models -
Materialization = How dbt builds the model:
view- just a SQL view (no data stored)table- actual table with dataincremental- only process new/changed dataephemeral- CTE that gets inlined
-
Tests = Data quality checks run with
dbt test
Usage #
# Run all models
uv run dbt run
# Run specific model
uv run dbt run --select user_segments
# Run tests
uv run dbt test
# Generate and serve documentation
uv run dbt docs generate
uv run dbt docs serve
Setup #
This project uses:
- dbt-bigquery for data transformations
- BigQuery public datasets (
bigquery-public-data.thelook_ecommerce.*) - Application Default Credentials for authentication
Authentication was set up using:
gcloud auth application-default login
Next Steps #
Explore more by:
- Adding order/product models from the same public dataset
- Creating metrics (total revenue, orders per user, etc.)
- Building a DAG with multiple layers (staging → intermediate → marts)