Cross-model queries
Combine related business entities in a single governed analytical request.
Cross-model queries let you combine measures and dimensions from related models. They only work when the semantic graph gives the transpiler a valid and safe join path.
Mixing measures and dimensions from different models requires a join path in the transpiler. Three rules decide what works.
Rule 1: Directionality
A join is only traversable from the model that declares it. Joins live in model.joins[].
In a clothing retail catalog:
customers.joins→orders(one_to_many),store_visits(one_to_many)orders.joinsis empty
Valid: orders.store_region as a dimension while measuring customers.total_customers (customers declares the join).
Invalid: customers.country as a dimension while measuring orders.total_units (orders declares no path to customers).
Check joins[] on the model that owns your measure. Only declared targets are reachable.
Rule 2: Fan-out
Crossing a one_to_many edge from the measure's model and grouping by a dimension on the many side inflates the measure. A customer with three orders appears three times when you group by orders.store_region, so customers.total_customers counts each customer three times.
Safe patterns:
Filter across the join without grouping by the many-side dimension (filter
orders.status = deliveredwhile counting customers).Put the measure on the many-side model (
orders.total_revenuebyorders.store_region).
When in doubt, measure from the model that owns what you are counting. Use joins to filter, not to group.
Rule 3: Ambiguous paths and joinHints
When multiple paths connect two models, the transpiler picks the shortest by hop count, which may not match business intent.
Set an explicit path in REST:
Or encode the path in a member name:
joinHints is a REST request field and is not exposed by GraphQL. In Semantic SQL, model order and CROSS JOIN shape communicate the requested models; there is no separate request-body joinHints field.
Safe patterns
Semantic SQL equivalent for the filter-across-join case:
Patterns to avoid
Transpiler error: no join path.
No error. Silent count inflation.
Last updated
Was this helpful?