You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor create_or_update_genie function for improved handling of serialized_space
- Streamline logic for updating or creating Genie spaces based on the presence of serialized_space and space_id.
- Enhance error handling for non-existent spaces and ensure proper updates are made when serialized_space is provided.
- Update documentation to clarify the workflow for creating and updating Genie spaces, including handling sample questions.
Copy file name to clipboardExpand all lines: databricks-skills/databricks-genie/SKILL.md
+76-10Lines changed: 76 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,28 +113,92 @@ import_genie(
113
113
114
114
#### Example: Migrating Genie Spaces from Prod to Dev
115
115
116
-
When migrating Genie Spaces between environments (e.g., from a `prod` target to a `dev` target defined in your `databricks.yml`), you must update the catalog references within the serialized space.
116
+
When migrating Genie Spaces between environments (e.g., from a `prod` target to a `dev` target defined in your `databricks.yml`), you must update the catalog references within the serialized space.
117
117
118
118
**Note:** Genie Space migration assumes that the underlying data assets (schemas and tables) remain structurally identical across environments. The migration of the actual catalogs, schemas, or tables themselves is outside the scope of Genie Space migration skills.
119
119
120
-
For instance, if your production tables reside in the `healthverity_claims_sample_patient_dataset` catalog, but your development tables are in `healthverity_claims_sample_patient_dataset_dev`, you can perform a string replacement on the exported configuration before importing it into the target workspace:
120
+
##### The Challenge: MCP Servers Are Workspace-Scoped
121
+
122
+
Each Databricks MCP server instance connects to exactly one workspace (set via `DATABRICKS_CONFIG_PROFILE` at startup). This means a single MCP server cannot export from PROD and import into DEV in the same session — you need two server instances.
123
+
124
+
##### Recommended Setup: Dual MCP Server Profiles
125
+
126
+
Configure two Databricks MCP server entries in your IDE's MCP config (e.g. `~/.cursor/mcp.json`), one per workspace:
Both servers run simultaneously after one IDE reload. This lets you call `export_genie` against `databricks-prod` and `import_genie` against `databricks-dev` within the same conversation — no further reloads needed.
142
+
143
+
> **Tip:** The Databricks CLI profiles (`prod`, `dev`) referenced above must be defined in `~/.databrickscfg`. Both token-based and OAuth (`auth_type = databricks-cli`) profiles are supported.
144
+
145
+
##### Full Migration Workflow
146
+
147
+
**Step 1 — Export from PROD** using the `databricks-prod` MCP server:
121
148
122
149
```python
123
-
#1. Export the Genie Space from the production workspace
**Step 5 — Save exports locally** for version control and future re-migrations:
193
+
194
+
```json
195
+
// genie_exports/MySpace.json
196
+
{
197
+
"space_id": "<prod_space_id>",
198
+
"title": "MySpace",
199
+
"warehouse_id": "<prod_warehouse_id>",
200
+
"serialized_space": "{ ... }"
201
+
}
138
202
```
139
203
140
204
## Workflow
@@ -176,7 +240,9 @@ Use these skills in sequence:
176
240
|**`import_genie` fails with permission error**| Ensure you have CREATE privileges in the target workspace folder |
177
241
|**Tables not found after migration**| Catalog name was not remapped — replace the source catalog name in `serialized_space` before calling `import_genie`|
178
242
|**Catalog name appears in SQL queries too**|`serialized_space` embeds catalog in table identifiers, SQL FROM clauses, join specs, and filters — a single `.replace(src, tgt)` on the whole string covers all occurrences |
179
-
243
+
|**`export_genie` / `import_genie` land in the wrong workspace**| Each MCP server is workspace-scoped. Set up two named MCP server entries (one per profile) in your IDE's MCP config instead of switching a single server's profile mid-session |
244
+
|**MCP server doesn't pick up profile change**| The MCP process reads `DATABRICKS_CONFIG_PROFILE` once at startup — editing the config file requires an IDE reload to take effect |
245
+
|**`import_genie` fails with JSON parse error**| The `serialized_space` string may contain multi-line SQL arrays with `\n` escape sequences; flatten SQL arrays to single-line strings before passing to avoid double-escaping issues |
180
246
## Related Skills
181
247
182
248
-**[databricks-agent-bricks](../databricks-agent-bricks/SKILL.md)** - Use Genie Spaces as agents inside Supervisor Agents
0 commit comments