.sql file stored in a workspace and organized into layers — bronze, silver, gold, or platinum. When you save a model, Soria automatically commits it to GitHub, updates the workspace PR, and applies the view to the warehouse.
Model file format
Every SQL model must include a header comment block and aMODEL block. The @category annotation is required — it controls which section the model appears in on the dashboard.
Optional annotations
Layer requirements
Bronze — raw source ingestion
Bronze — raw source ingestion
Bronze models represent raw source data as delivered by scrapers. No transformations should occur at this layer.
Silver — typed, cleaned staging
Silver — typed, cleaned staging
Silver models apply type casting and cleaning to a single source table. Strict rules apply:
- Every
src_CTE must beSELECT * FROM sourcewith no column transforms or filters. - All output columns must have explicit type casts using
CAST(col AS type)orcol::typesyntax. - Silver models must not contain JOINs. Joins belong in the gold layer.
- Every output column must have an entry in
column_descriptionsinside theMODELblock.
Gold — joined, business-ready models
Gold — joined, business-ready models
Gold models join across silver models to produce business-ready datasets.
- Joins across silver models are expected and correct at this layer.
- Column descriptions remain required for all output columns.
- Gold models are candidates for materialization after promotion (see
warehouse_materialize).
Platinum — dashboard-ready outputs
Platinum — dashboard-ready outputs
Platinum models power dashboard charts and are the final output layer.
- May include a
@dashboardYAML annotation block in the header comment to configure chart type, axes, and filters. - Dashboard config is validated on save;
warehouse_materializeis run automatically on promote.
sql_model_save
Save (create or update) a SQL model in a workspace.Parameters
string
required
The ID of the workspace where the model will be saved, e.g.
ws_ma_star_ratings_8a3f1b92.string
required
Path to the model file within the workspace, e.g.
medicare_advantage/star_ratings.sql. The path determines the model’s location in the GitHub repository.string
required
Data layer for the model. Must be one of:
bronze, silver, gold, platinum.string
required
Full SQL source, including the header comment block (with
@category) and the MODEL block. Validation runs on every save — see validation rules below.string
Name or identifier of the person making the edit. Recorded in the model’s metadata and shown in the workspace model list.
What happens on save
1
Validation
Soria validates the model against layer-specific rules. If validation fails, the model is not saved and a quality report is returned describing the errors.
2
Saved to workspace
The model is written to the workspace’s model store and versioned.
3
GitHub commit
Soria commits the file to the workspace branch and updates the open pull request.
4
View auto-apply
The corresponding view is created or replaced in the warehouse. If auto-apply fails, the model is still saved but you will see a warning — fix the SQL and re-save to retry.
Validation
Every save runs validation against the model’s content. Common failure reasons:- Missing
@categoryannotation in the header comment. src_CTEs that do anything other thanSELECT * FROM source.- Silver model contains a
JOIN. - Silver model columns lack explicit type casts.
- Output columns missing from
column_descriptions.
Example
sql_model_list
List all SQL models saved in a workspace.Parameters
string
required
The workspace to list models from.
Response
Returns each model’spath, layer, and updated_at timestamp, sorted by last update.
Example
sql_model_get
Retrieve the full content of a SQL model by path.Parameters
string
required
The workspace the model belongs to.
string
required
Path to the model file, e.g.
medicare_advantage/star_ratings.sql.Example
sql_model_delete
Delete a SQL model from a workspace.Parameters
string
required
The workspace the model belongs to.
string
required
Path to the model file to delete, e.g.
medicare_advantage/star_ratings.sql.