recommend_root_model
Identifies the optimal source model for a set of columns and metrics, returning join-qualified paths for each item. Handles unreachable items by suggesting partial roots for multi-stage queries.
Instructions
Recommend the root model (query source_model) for a set of
model.column / model.metric items, and give each item's
join-qualified reference path from that root.
Introspects the join graph and picks the model from which every
requested item is reachable (LEFT joins are directional; INNER
joins traverse both ways), minimizing total join hops. The returned
paths are ready to drop into a query whose source_model is the
recommended root — e.g. a joined column comes back as
customers.regions.name and a root-owned one as status;
aggregation spellings (sum(revenue) / revenue:sum) are preserved.
When no single model reaches everything, root_model is null and
coverage lists the best partial roots so you can split the
request into a multi-stage query.
Call this once your item list is final, not as a schema browser —
explore with search / inspect first.
Args:
items: entity references (orders.revenue, customers.name,
orders.revenue:sum / sum(orders.revenue), bare aov for a saved metric...).
data_source: optional datasource scope; when omitted, names
resolve via the datasource-priority list. All items must
resolve to a single datasource.
root_hint: optional intended root — a bare model name or
<data_source>.<model> within the resolved datasource.
Honored when it reaches every item (overriding the min-hops
pick, so you can force a bridge model that owns none of the
items); otherwise the auto-pick is used and a warning
explains why. Resolved after the datasource is determined,
so it cannot pick the datasource.
format: "markdown" (default) or "json".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | ||
| format | No | markdown | |
| root_hint | No | ||
| data_source | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |