Semantic SQL
A SQL-oriented interface for analyzing governed business definitions.
Use Semantic SQL when analysts want SQL authoring while keeping calculations governed by the Data Product. The query references semantic models and members; Vulcan compiles it into warehouse SQL before execution.
Semantic SQL is a strong fit for exploration, notebooks, and SQL-native tools. Prefer REST for programmatically generated queries because structured JSON is safer to compose than SQL strings.
Endpoint: POST /api/v1/query/semantic/sql
Query rules
Submit read-only
SELECTstatements.Reference dimensions as
<model>.<dimension>.Wrap every governed measure in
MEASURE(<model>.<measure>).Group by selected dimensions when the query contains a measure.
Use
WHEREfor dimensions and segments; useHAVINGfor aggregated measures.Use a semantic join only when metadata defines a valid relationship between the models.
Do not submit DML or DDL such as
INSERT,UPDATE,DELETE,CREATE,DROP, orALTER.
Please note that the query format described here is the only supported one. Ad-hoc queries that use native MySQL functions or syntax outside this format may only work partially or silently return incorrect results, so we recommend avoiding them.
Semantic model mapping
Every semantic model and metric in your Data Product is exposed as a table. Its measures and dimensions become columns.
Semantic model or metric
Table
Dimension
Column. Select directly.
Measure
Column. Wrap with MEASURE() or a matching aggregate.
Segment
Boolean column: WHERE seg IS TRUE.
Querying a model
Treat a semantic model or metric like any table:
Dimensions
Dimensions are plain columns. Reference them in SELECT, WHERE, GROUP BY, or ORDER BY:
Filter by a dimension:
Measures
Wrap measures with the MEASURE() aggregate, or with an aggregate that matches the measure type (see below).
Use
MEASURE()by default. It works for every measure type and avoids type mismatch errors.
MEASURE() works with every measure type. You can also use a type-specific aggregate, but it has to match exactly. Otherwise the API throws Measure aggregation type doesn't match.
avg
MEASURE or AVG
boolean
MEASURE
count
MEASURE or COUNT
count_distinct
MEASURE or COUNT(DISTINCT ...)
max
MEASURE or MAX
min
MEASURE or MIN
number
MEASURE or any function from this table
string
MEASURE or STRING_AGG
sum
MEASURE or SUM
time
MEASURE, MAX, or MIN
Joining models
The semantic layer already defines relationships between models. To query across models, use one of three forms: CROSS JOIN, comma-separated tables, or LEFT JOIN with the __joinField key.
__joinField is a virtual column on every model. It carries the join key the semantic layer uses. You do not define the join condition; you reference __joinField on both sides.
LEFT JOIN using __joinField:
CROSS JOIN:
Comma-separated (implicit join):
All three are equivalent. Pick whichever reads most clearly.
Supported filter operators
IN
Exact match. Supports multiple values.
string, number, time
WHERE customers.country IN ('US', 'UK', 'India')
NOT IN
Inverse of IN. Supports multiple values.
string, number, time
WHERE customers.country NOT IN ('France')
LIKE
Case-insensitive wildcard match. Supports multiple values.
string
WHERE products.brand LIKE '%nike%' OR products.brand LIKE '%adidas%'
NOT LIKE
Inverse of LIKE. Supports multiple values.
string
WHERE products.brand NOT LIKE '%nike%' AND products.brand NOT LIKE '%adidas%'
>
Greater than.
number
WHERE orders.total_units > 100
>=
Greater than or equal to.
number
WHERE orders.total_units >= 100
<
Less than.
number
WHERE orders.total_units < 100
<=
Less than or equal to.
number
WHERE orders.total_units <= 100
IS NOT NULL
Member is not NULL.
number, string, time
WHERE customers.phone_number IS NOT NULL
IS NULL
Member is NULL.
number, string, time
WHERE customers.phone_number IS NULL
BETWEEN
Restricts a time dimension to a date range.
time
WHERE orders.order_date BETWEEN '2025-01-01' AND '2025-12-31'
NOT BETWEEN
Inverse of BETWEEN.
time
WHERE orders.order_date NOT BETWEEN '2025-01-01' AND '2025-12-31'
< (date)
Everything before a date.
time
WHERE orders.order_date < '2025-01-01'
> (date)
Everything after a date.
time
WHERE orders.order_date > '2025-01-01'
Scenario 1: One dimension, one measure, one filter
Total order count per status, delivered orders only:
Scenario 2: One dimension, multiple measures, with a filter
Order count, total revenue, and average order value per store region, current year only:
Scenario 3: Two models with a cross-model measure
Total order count per product name, across orders and products, limited to 2025:
Scenario 4: Two models with WHERE and HAVING
Product name and total revenue for products with more than 500 delivered orders:
Quick reference
Introspection
Use these to see what is available before writing queries:
Access-policy warnings
When a query returns no rows, inspect the warnings to determine whether an access policy restricted the result:
Example response:
Note: If an access policy is applied,
SHOW WARNINGS;indicates that it may have restricted the query results.
Common patterns
Transpile without executing
Use POST /api/v1/query/semantic/sql?transpile_only=true. A successful request returns 200 with compiled SQL and parameters; no statement is created.
Normal execution returns 202 Accepted. Continue with the query lifecycle.
Next steps
See Cross-model queries before combining related semantic models.
Last updated
Was this helpful?