Skip to main content
SQL models are the building blocks of every Soria dashboard. Each model is a SQL file that defines a view or table in your data warehouse. Models are organized into four pipeline layers, and platinum-layer models become the interactive charts you see on the dashboard home page.

Pipeline layers

Bronze

Raw source tables auto-created from extraction. You don’t write bronze models — Soria creates them when data is ingested.

Silver

Cleaned and typed data. Use explicit CAST or :: type conversions. No JOINs allowed — joins belong in gold.

Gold

Joined data across silver models. This is where you combine related datasets and build richer views.

Platinum

Aggregated, dashboard-ready views. Platinum models can include a @dashboard chart config that controls how the data is visualized.

Model structure

Every SQL model must include a header comment with a @category annotation. This tells Soria which category section the model belongs to on the dashboard home page.

Annotations

Layer rules

Silver models:
  • Use SELECT * FROM source CTEs prefixed with src_ — no transforms in the CTE itself.
  • Apply all type conversions with explicit CAST(col AS type) or col::type syntax.
  • No JOIN statements. Silver is for cleaning, not combining.
Gold models:
  • Join across silver models to build richer datasets.
  • Reference silver views using their schema-qualified names.
Platinum models:
  • Aggregate data into the final shape for charts.
  • Optionally include a @dashboard annotation with YAML chart configuration:

Creating and updating models

Use sql_model_save to create a new model or overwrite an existing one. After saving, Soria automatically:
  • Commits the model file to GitHub and updates the pull request.
  • Applies the view to your workspace’s data warehouse.
If the SQL is invalid, the model is saved to GitHub but the warehouse view is not updated. The response will include a warning with the apply error. Fix the SQL and re-save to apply the view.

Path format

The path argument uses the format category_folder/model_name.sql. The path determines how the file is organized in the repository.

Listing and reading models

Use sql_model_list to see all models saved in a workspace:
Use sql_model_get to read the content of a specific model:

Deleting a model

Deleting a model removes it from the repository and drops the corresponding view from the warehouse. This cannot be undone without re-saving the model.

Exploring data before writing models

Use warehouse_query to profile and explore data in the warehouse before you start writing a model. This is especially useful when you’re working with a new bronze source and need to understand its shape.
Omit workspace_id to query production data directly.