Data Models
What a Vulcan data model is: the MODEL block, the SELECT query, naming and typing conventions, comment registration, and the day-to-day workflow for adding, editing, and deleting models.
Models transform raw data into tables and views. Define what you want (the metadata) and how to make it (the SQL query), and Vulcan handles the rest.
Models live in .sql and .py files in the models/ directory of your project. Vulcan automatically figures out how your models relate to each other by parsing your SQL, so you don't have to manually configure dependencies. Write your SQL, and Vulcan handles the lineage.
Every model has 2 parts:
DDL (Data Definition Language) - The
MODELblock that tells Vulcan what this model is (name, schedule, how to materialize it, etc.)DML (Data Manipulation Language) - The
SELECTquery that does the actual transformation work
The DDL defines the model metadata. The DML contains the transformation logic.
Model structure
You can write models in SQL or Python. Both work the same way conceptually; they just look different. Let's see both:
MODEL (
name sales.daily_sales,
kind FULL,
cron '@daily',
grains (order_date),
tags ('silver', 'sales', 'aggregation'),
terms ('sales.daily_metrics', 'analytics.sales_summary'),
description 'Daily sales summary with order counts and revenue',
column_descriptions (
order_date = 'Date of the sales transactions',
total_orders = 'Total number of orders for the day',
total_revenue = 'Total revenue for the day',
last_order_id = 'Last order ID processed for the day'
),
column_tags (
order_date = ('dimension', 'grain', 'date'),
total_orders = ('measure', 'count'),
total_revenue = ('measure', 'financial'),
last_order_id = ('dimension', 'identifier')
)
);
SELECT
CAST(order_date AS TIMESTAMP)::TIMESTAMP AS order_date,
COUNT(order_id)::INTEGER AS total_orders,
SUM(total_amount)::FLOAT AS total_revenue,
MAX(order_id)::VARCHAR AS last_order_id
FROM raw.raw_orders
GROUP BY order_date
ORDER BY order_dateBreaking it down:
Lines 1-21: The DDL (
MODELblock) - tells Vulcan this is a daily sales model with metadata, tags, and column documentationLines 23-31: The DML (
SELECTquery) - the actual transformation that aggregates orders by date
Breaking it down:
Lines 7-34: The DDL (
@modeldecorator) - same metadata as SQL with tags, terms, and column documentationLines 35-54: The DML (function body) - runs the SQL and returns a DataFrame
Both formats do the same thing. Choose the one you prefer.
DDL: the MODEL block
The MODEL block is where you tell Vulcan about your model. It's the first thing in your file (after any comments) and uses a simple, declarative syntax.
Basic syntax
Here's what a MODEL block looks like:
This tells Vulcan:
name- What to call this model (schema.tableorcatalog.schema.tableif targeting a non-default database)kind- How to materialize it (FULL rebuilds everything, INCREMENTAL only updates changes, etc.)cron- When to run it (@dailymeans every day)grains- What makes each row unique (uses tuple syntax with parentheses)tags- Labels for categorization (uses tuple syntax)terms- Business glossary terms using dot notationdescription- Human-readable description of the model
Common properties
Here are the properties you'll use most often:
name
Fully qualified model name (schema.table or catalog.schema.table)
sales.daily_sales
kind
Materialization strategy
FULL, INCREMENTAL, VIEW
cron
When to run (scheduling)
'@daily', '0 0 * * *'
grains
Column(s) that make rows unique
(order_date) or (customer_id, order_date)
owner
Who owns this model (for governance)
analytics_team
description
Human-readable description
'Daily sales aggregates'
tags
Labels for organizing models
('gold', 'analytics', 'customer')
terms
Business glossary terms
('customer.rfm_analysis')
DML: the SELECT query
The SELECT is the transformation. Vulcan wraps it with the right DDL and DML for the model kind (CREATE OR REPLACE, INSERT, MERGE, and so on), but the shape of the output is entirely whatever this query returns.
This query:
Reads from
raw.raw_ordersGroups by
order_dateCounts orders, sums revenue, finds the latest order ID
Returns the results ordered by date
Pretty standard SQL! Vulcan automatically figures out that this model depends on raw.raw_orders and builds the dependency graph for you.
Conventions
Vulcan infers as much as possible from your SQL. This means you don't have to write a bunch of YAML config files, just write SQL and Vulcan figures it out. But to do this, your SQL needs to follow some conventions.
SQL model conventions
Two rules Vulcan expects your SELECT to follow so it can infer schema correctly.
Unique column names
Your final SELECT needs unique column names. No duplicates allowed!
If you have duplicate column names, Vulcan won't know which one you mean, and that causes problems.
Explicit types
Cast your types explicitly. This prevents surprises and ensures your schema is consistent:
Vulcan uses PostgreSQL-style casting (x::int), but don't worry, it automatically converts this to whatever your execution engine needs. So you write ::INTEGER and Vulcan handles the rest.
Why this matters: Without explicit types, you might get FLOAT when you expected INTEGER, or VARCHAR when you wanted TIMESTAMP. Explicit casting prevents these surprises.
Inferrable names
Your columns need names that Vulcan can figure out. If Vulcan can't infer a name, you need to add an alias:
If you forget an alias, Vulcan's formatter adds one automatically when it renders your SQL. But it's better to be explicit: you'll know what the column is called!
Column metadata
Document and categorize your columns using column-level metadata properties. There are several options:
Column Descriptions (Recommended)
This keeps all your documentation in one place, in the MODEL block.
Column Tags and Terms
Beyond descriptions, you can also add tags and business glossary terms to columns:
column_tags- Categorize columns by role (dimension,measure), sensitivity (pii), or purposecolumn_terms- Link columns to business glossary terms for semantic understanding
See Model Properties for detailed documentation on all column-level metadata options.
Option 2: Inline Comments
If you don't specify column_descriptions in the DDL, Vulcan automatically picks up comments from your query:
Vulcan registers these comments as column descriptions in your database.
Table comments: If you put a comment before the MODEL block, Vulcan uses it as the table description. But if you also specify description in the MODEL block, that takes priority.
Python model conventions
Python models work a bit differently because Python doesn't have the same type inference capabilities as SQL.
Explicit column definitions
You must define your columns explicitly in the @model decorator:
Vulcan can't infer types from Python code the way it can from SQL, so you need to tell it explicitly.
Explicit dependencies
Unlike SQL models (where Vulcan figures out dependencies automatically), Python models need you to list them:
This is because Vulcan can't parse your Python code to find FROM clauses and joins. You need to tell it what this model depends on.
Column metadata
Python models can't use inline comments for column descriptions. Instead, specify them in the decorator using column_descriptions, column_tags, and column_terms:
Return type
Your execute function must return a pandas DataFrame, and the columns must match what you defined in columns:
The DataFrame columns need to match your columns definition exactly: same names, compatible types.
Comment registration
Vulcan registers comments (descriptions) in your database so they show up in your BI tools and data catalogs.
How comments get registered
Model-level comments:
If you put a comment before the
MODELblock, Vulcan uses it as the table commentIf you also specify
descriptionin the MODEL block, that takes priority
Column-level comments:
Use
column_descriptionsin the DDL (recommended)Or use inline comments in your SELECT query (if
column_descriptionsisn't specified)
What gets registered
Not everything gets comments registered:
Physical tables - Comments are registered (tables in the
vulcan__[project schema]schema)Production views - Comments are registered
Temporary tables - No comments (they're temporary)
Non-production views - No comments (keeps things clean)
Note: Some engines automatically pass comments from physical tables to views that select from them. So even if Vulcan didn't explicitly register a comment on a view, it might still show up if the engine does this automatically.
Engine support
Different databases support comments differently. Some can register comments in the CREATE statement (one command), others need separate commands for each comment.
Here's what each engine supports:
Engine
TABLE comments
VIEW comments
Postgres
Y
Y
Snowflake
Y
Y
Spark
Y
Y
If your engine doesn't support comments, Vulcan skips registration (no errors, it just doesn't register them).
Macros
Macros are like variables for your SQL. They let you parameterize queries and avoid repetition. Vulcan provides several built-in macros (like @start_ds and @end_ds for incremental models), and you can define your own.
Macros use the @ prefix. For example, @this_model refers to the current model being processed, and @start_ds is the start date for incremental processing.
See the macros documentation for details.
Working with models
Add, edit, evaluate, and delete models using an Orders360 example project.
Add a model
Create a file in your models directory:
Define the model:
Confirm Vulcan detects it, then apply it:
vulcan plan shows the new model and the dates it needs to backfill before asking you to confirm.
Evaluate a model
vulcan evaluate runs a model's query without materializing it, a dry run for testing logic and previewing output:
Use evaluate to test transformations, debug queries, and check data quality before you commit to a plan.
Edit a model
Change the query, then preview the impact with vulcan plan before applying to production.
Vulcan classifies the change:
Non-breaking (e.g. adding a column): existing queries still work, and downstream models that don't use the new column aren't reprocessed.
Breaking (e.g. adding a
WHEREfilter): downstream models depending on the changed model become indirectly modified and need backfill too. Vulcan processes upstream models first.
Review the diff and backfill scope in the plan output before applying. Breaking changes cost more because they cascade, so confirm you need one before making it.
Revert a change
Undo an edit and apply it with vulcan plan. Vulcan detects the model is back to what production already has and offers a Virtual Update: no backfill, just a fast reference change, so previous data stays available and the revert completes in seconds.
Delete a model
Remove the file (and any associated tests), then apply:
Vulcan applies the removal as a virtual update in dev. Then repeat vulcan plan against production.
Validate models
Vulcan validates automatically on plan (unit tests, then assertions as data loads). You can also validate manually:
vulcan evaluate <model>: preview output without materializingvulcan test: run unit tests intests/vulcan plan: preview changes before applying
Best practices
Use descriptive names (
sales.daily_sales, notsales.ds).Add column descriptions so documentation lives with the model.
Use assertions to validate data quality at the model level.
Test with
evaluatebefore applying changes.Review plan diffs and downstream impact carefully.
Develop in a dev environment; don't test in prod.
Related pages
The complete reference for every MODEL DDL property.
SQL, Python, and external models, and how to choose between them.
How each model kind loads and processes data: FULL, INCREMENTAL, VIEW, SCD, and more.
Pre-statements, post-statements, and on-virtual-update statements.
Last updated
Was this helpful?