The four layers
The warehouse uses a layered model where each layer has a specific purpose. You build SQL models to transform data as it moves up the layers.Bronze
Raw source data. Files land here automatically after extraction. One table per group. No transformations applied — this is the data exactly as extracted.
Silver
Cleaned and typed data. Explicit type casts (no implicit conversions), no JOINs, one source per model. This is where you enforce data types and clean up inconsistencies.
Gold
Joined data. Combine silver models across sources here. Gold is where cross-source analysis becomes possible.
Platinum
Dashboard-ready aggregations. Platinum models can include chart configuration that controls how data appears in dashboards.
bronze → silver → gold → platinum
Publishing to bronze
When you runwarehouse_manage(publish=True) for a group, all extracted CSVs for that group are loaded into a bronze table. Column mappings and value mappings are applied automatically at publish time — the warehouse always sees canonical names and values.
Publishing requires a workspace. Changes don’t reach production until you promote the workspace with
workspace_manage(operation="promote", workspace_id="<id>").Rebuilding a table
If you need to rebuild a table from scratch — for example, after changing your schema columns — useforce=True:
force=True drops and recreates the table before loading.
Querying the warehouse
Usewarehouse_query to explore data at any layer using DuckDB SQL. This is how you profile data before writing SQL models and verify that published data looks correct.
workspace_id to query a workspace’s data (where in-progress changes live). Omit it to query production.
Useful query patterns
Profile a table’s columns and statistics:SUMMARIZE returns column-level statistics: min, max, approximate distinct count, null count, and more. It’s the fastest way to understand a new table.
Building SQL models
Bronze tables are automatically created by the pipeline. Silver, gold, and platinum models are SQL models that you write and save usingsql_model_save.
Each model is a SQLMesh SQL file with a MODEL block that defines its name, layer, and column descriptions. See SQL Models for how to write and save models.
Silver model rules:
- Explicit type casts on every column (
CAST(col AS INTEGER)orcol::INTEGER) - No JOINs — one source per model
- Source CTEs must be
SELECT * FROM sourcewith no transforms
- JOINs across silver models are allowed here
- No aggregations — save those for platinum
- Aggregations and final calculations
- Can include a
@dashboardYAML annotation for chart configuration
Table history
Each time you publish and promote, the warehouse records a snapshot. You can inspect this history to understand when data changed and what workspace made the change:Removing data
To remove specific files from a warehouse table:file_ids drops the whole table.