upsert_model
Create or update a semantic model and its graph entity, merging fields and configuring calendars, keys, entities, and preferences for governed analytics.
Instructions
Upsert a model and its graph entity. calendar: true makes it the package calendar for calendar_id (default "default", which a package with calendars needs), its columns ordinary dimensions; time.fill and time buckets stay Gregorian. false reverts it. calendar_id on a regular model binds its times to a calendar (only the default in this release). Fields merge into an existing model: a dimension, time or measure given only label, description, synonyms or meta keeps its other fields; given more, it is rewritten. replace: true rewrites the model from the arguments, keeping its id, entities, calendar_id, zero_through (how far its tables are loaded), one_per_key, prefer_over and distinct_from. dropped_fields lists what a rewrite drops. one_per_key: true reads a relation whose rows repeat the key as one row per primary_key, each column the key's one value (NULL where its rows disagree); put columns that vary on a row-grain model of the same relation. prefer_over: look-alike model ids it answers for; [] removes. primary_key [] makes a row-grain model (no key); entities ({parent: {} or {expr: column}}) merges parent entities. Relate models with upsert_relationship.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_path": "<project_path>",
"model_id": "<model_id>",
"entity_key": "<entity_key>",
"relation": "<relation>",
"primary_key": "<primary_key>",
"expected_revision": "<expected_revision>",
"idempotency_key": "<idempotency_key>"
},
"name": "upsert_model"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| group | No | core | |
| label | No | ||
| times | No | ||
| dry_run | No | ||
| replace | No | ||
| calendar | No | ||
| entities | No | ||
| measures | No | ||
| model_id | Yes | ||
| relation | Yes | ||
| dimensions | No | ||
| entity_key | Yes | ||
| calendar_id | No | ||
| description | No | ||
| full_report | No | true: the whole report, not a summary | |
| one_per_key | No | ||
| prefer_over | No | ||
| primary_key | Yes | ||
| project_path | Yes | ||
| idempotency_key | Yes | ||
| expected_revision | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| error | No | ||
| parse | No | ||
| errors | No | ||
| status | Yes | ||
| changes | Yes | ||
| dry_run | Yes | ||
| revision | Yes | ||
| project_path | Yes | ||
| base_revision | Yes | ||
| changed_files | Yes | ||
| route_changes | No | ||
| workspace_root | No | ||
| idempotency_key | Yes | ||
| current_revision | Yes | ||
| expected_revision | Yes | ||
| idempotent_replay | Yes | ||
| proposed_revision | Yes | ||
| route_decisions_added | No |