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
# Use ai_query only for deeply nested schemas that exceed ai_extract's 7-level limit
176
+
# Use ai_query only for deeply nested schemas that exceed ai_extract's 12-level limit
177
177
178
178
@dlt.table(comment="Nested line items extracted — ai_query used for array schema only")
179
179
defextracted_line_items():
@@ -496,7 +496,7 @@ with mlflow.start_run():
496
496
## Tips
497
497
498
498
1.**Parse first, enrich second** — always run `ai_parse_document` as the first stage. Feed its text output to task-specific functions; never pass raw binary to `ai_query`.
499
-
2.**Flat or nested fields → `ai_extract`; deeply nested JSON exceeding 7 levels → `ai_query`** — pass `MAP('version', '2.0')` and access results through `:response`.
499
+
2.**Flat or nested fields → `ai_extract`; deeply nested JSON exceeding 12 levels → `ai_query`** — pass `MAP('version', '2.0')` and access results through `:response`.
500
500
3.**`failOnError => false` is mandatory in batch** — write errors to a sidecar `_errors` table rather than crashing the pipeline.
501
501
4.**Truncate before sending to `ai_query`** — use `LEFT(text, 6000)` or chunk long documents to stay within context window limits.
502
502
5.**Prompts belong in `config.yml`** — never hardcode prompt strings in pipeline code. A prompt change should be a config change, not a code change.
Copy file name to clipboardExpand all lines: skills/databricks-aibi-dashboards/SKILL.md
+14-7Lines changed: 14 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,15 +90,18 @@ Sample rows alone don't tell you what to build. you can write aggregate SQL thro
90
90
-**Trend viability** at daily/weekly/monthly grain → picks the right trend granularity.
91
91
-**Story confirmation** — run the aggregations you plan to put in the dashboard and check they're not flat, empty, or uninteresting. Fix the query or adjust the story before moving on.
92
92
93
-
Fan out independent probes (state ∈ `PENDING|RUNNING|SUCCEEDED|FAILED|CANCELED|CLOSED`):
93
+
Fan out independent probes in one call — pass several positional SQLs (and/or repeated `--file`) and they run in parallel (default `--concurrency 8`):
94
94
95
95
```bash
96
-
submit() { databricks api post /api/2.0/sql/statements --json "$(jq -nc --arg w "$1" --arg s "$2"'{warehouse_id:$w,statement:$s,wait_timeout:"0s",on_wait_timeout:"CONTINUE"}')"| jq -r .statement_id; }
"SELECT region, COUNT(*) FROM catalog.schema.orders GROUP BY region ORDER BY 2 DESC LIMIT 10" \
99
+
"SELECT MIN(ts), MAX(ts) FROM catalog.schema.orders"
100
100
```
101
101
102
+
-**`--output json` is mandatory** in multi-query mode. Returns one object per statement: `{sql, state, rows, error}`; failures are per-statement (`state: "FAILED"`), others still succeed.
103
+
- ⚠️ **Don't trust the exit code** (a failed statement can still exit `0`) — gate on each object's `state != "SUCCEEDED"`.
104
+
102
105
> **Dashboard queries are different** — inside the dashboard JSON, the `FROM` clause must reference ONLY the table name, with no catalog or schema prefix:
103
106
> - ✅ Correct: `FROM trips`
104
107
> - ❌ Wrong: `FROM nyctaxi.trips`
@@ -120,7 +123,9 @@ If values don't match expectations, ensure the query is correct, fix the data if
120
123
121
124
Before writing JSON, plan your dashboard:
122
125
123
-
1. You must know the expected specific JSON structure. For this, **Read reference files**: [1-widget-specifications.md](references/1-widget-specifications.md), [3-filters.md](references/3-filters.md), [4-examples.md](references/4-examples.md)
126
+
1. You must know the expected specific JSON structure. For this, **Read reference files**: [1-widget-specifications.md](references/1-widget-specifications.md), [3-filters.md](references/3-filters.md).
127
+
128
+
Always make sure you read an entire example to understand the structure, like [4-examples.md](references/4-examples.md).
124
129
125
130
2. Think: **What widgets?** Map each visualization to a dataset:
Every dashboard's `serialized_dashboard` content must follow this exact structure:
194
199
200
+
Important: ALWAYS add a space or `\n` at the end of each `queryLines` value as they are concatenated to create the dataset.
201
+
195
202
```json
196
203
{
197
204
"datasets": [
@@ -215,7 +222,7 @@ Every dashboard's `serialized_dashboard` content must follow this exact structur
215
222
```
216
223
217
224
**Structural rules (violations cause "failed to parse serialized dashboard"):**
218
-
-`queryLines`: Array of strings, NOT `"query": "string"`. Elements are **joined verbatim** with no separator — end each line with `\n` (or strip `-- comments`). A line ending in `-- comment` with no newline swallows the next line.
225
+
-`queryLines`: Array of strings, NOT `"query": "string"`. Elements are **joined verbatim** with no separator — end each line with `` or `\n` (or strip `-- comments`). A line ending in `-- comment` with no newline swallows the next line.
219
226
- Widgets: INLINE in `layout[].widget`, NOT a separate `"widgets"` array
220
227
-`pageType`: Required on every page (`PAGE_TYPE_CANVAS` or `PAGE_TYPE_GLOBAL_FILTERS`)
221
228
- Query binding: `query.fields[].name` must exactly match `encodings.*.fieldName`
Copy file name to clipboardExpand all lines: skills/databricks-ml-training/SKILL.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: databricks-ml-training
3
-
description: "Train ML or custom-agent models on Databricks with MLflow tracking and Unity Catalog registration. Use when asked to: train classification/regression or deep-learning models (XGBoost, scikit-learn, LightGBM, PyTorch, etc.) with Optuna tuning, register to UC and promote `@prod`/`@challenger` aliases, batch-score via `spark_udf`, build custom PyFunc models, author a custom `ResponsesAgent` with UC Function/Vector Search tools, or submit a training notebook as a serverless one-time job. NOT for: endpoint ops (databricks-model-serving), Knowledge Assistants/Supervisor Agents (databricks-agent-bricks), MLflow evaluation (databricks-mlflow-evaluation)."
3
+
description: "Train ML models on Databricks. Use for: classification/regression/deep-learning (XGBoost, scikit-learn, LightGBM, PyTorch) with Optuna, @prod/@challenger aliases, batch scoring (spark_udf for plain models, fe.score_batch for feature-store-backed), custom PyFunc, custom ResponsesAgent (LangGraph + UC Function/Vector Search); UC feature tables + FeatureLookup + point-in-time joins + Lakebase online store; declarative Feature Views (create_feature, DeltaTableSource, RollingWindow/SlidingWindow/TumblingWindow, materialize_features, streaming Kafka features). NOT for: endpoint ops (databricks-model-serving), MLflow evaluation (databricks-mlflow-evaluation)."
@@ -19,7 +19,7 @@ If you need to deploy a real time model serving endpoint **after** the model is
19
19
20
20
| Consumption | When | How |
21
21
|---|---|---|
22
-
|**Batch UDF**| Dashboards, daily/hourly scores, predictions read by Genie/Dashboards or an app (often synced to a Lakebase table) |`mlflow.pyfunc.spark_udf(...)` → `INSERT INTO gold_predictions`|
22
+
|**Batch UDF**| Dashboards, daily/hourly scores, predictions read by Genie/Dashboards or an app (often synced to a Lakebase table) |`mlflow.pyfunc.spark_udf(...)` → `INSERT INTO gold_predictions`. **If the model was logged with `fe.log_model(training_set=...)`, use `fe.score_batch()` instead** — see the [Feature Engineering](#feature-engineering-feature-store--feature-views) section below.|
23
23
|**Real-time endpoint**| Score on a user action (fraud at authorization, rec at page load) — sub-100ms |`mlflow.deployments.get_deploy_client()` (classical) / `agents.deploy()` (agents). Endpoint lifecycle: see [databricks-model-serving](../databricks-model-serving/SKILL.md). |
gold_<entity>_predictions ◄── dashboards, apps, Genie read this
37
37
```
38
38
39
+
> **Feature-store-backed models diverge here.** If training used `fe.log_model(training_set=...)`, replace `spark_udf(@prod)` with `fe.score_batch(model_uri, df=<keys_only>)` — it auto-joins features via the model's registered feature lineage. See the [Feature Engineering](#feature-engineering-feature-store--feature-views) section below.
40
+
39
41
One notebook, one artifact. Re-running = retraining. Gold is where truth lives — read paths never call the model directly. Keep label-window logic (`failure occurred within 7 days`) in the notebook during dev; once stable, promote to a silver materialized view in SDP.
The cheap, default path. Load the registered model as a Spark UDF and score a Delta table; write predictions to a gold table that downstream consumers read.
130
+
The cheap, default path**for models NOT backed by feature tables**. Load the registered model as a Spark UDF and score a Delta table; write predictions to a gold table that downstream consumers read. **For feature-store-backed models** (logged with `fe.log_model(training_set=...)`), skip `spark_udf` entirely and use `fe.score_batch()` — see the [Feature Engineering](#feature-engineering-feature-store--feature-views) section.
129
131
130
132
```python
131
133
# COMMAND ----------
@@ -234,6 +236,19 @@ Prefer no-code authoring via [databricks-agent-bricks](../databricks-agent-brick
234
236
235
237
---
236
238
239
+
## Feature Engineering: Feature Store & Feature Views
240
+
241
+
When to reach for Feature Engineering (either flavor) instead of a plain Delta table: when the same feature must be computed identically at training and serving time (no training/serving skew), the feature is time-dependent and needs point-in-time joins against labels (no future leakage), the feature needs to be served with <10ms latency via an online store, or the feature is shared across models with lineage tracked in UC. If none apply, a plain UC table is enough — the sections below can be skipped.
242
+
243
+
**Default: don't use Feature Engineering unless one of the reasons above clearly applies or the user explicitly asked for it.** It adds build time and complexity (an extra Delta table layer for `FeatureLookup`; a materialization pipeline for Feature Views). If you're unsure, use plain UC tables and add Feature Engineering later when a concrete need surfaces.
244
+
245
+
Two flavors, one train/score path (`create_training_set` → `fe.log_model` → `fe.score_batch`):
246
+
247
+
-**`FeatureLookup` API** — you own the feature tables (compute, write, refresh); bind them to a training set via `FeatureLookup` + `FeatureEngineeringClient`. Reach for it when the features already exist as Delta tables or you want direct control over how they are computed. See **[references/feature-store.md](references/feature-store.md)**.
248
+
-**Feature Views** (declarative, Public Preview, `databricks-feature-engineering>=0.16.0`) — Databricks owns compute, materialization (Delta offline + Lakebase online), and refresh from a spec you declare (`create_feature` over `DeltaTableSource`; `RollingWindow`/`SlidingWindow`/`TumblingWindow`; `create_stream` for Kafka features). Reach for it when the feature is a formula you want Databricks to keep fresh. See **[references/feature-views.md](references/feature-views.md)**.
|[references/genai-agents.md](references/genai-agents.md)| Custom LangGraph `ResponsesAgent` with UC Function + Vector Search tools. `create_text_output_item` gotcha and the `resources=[...]` passthrough-auth list. For no-code agents prefer **databricks-agent-bricks**. |
273
+
|[references/feature-store.md](references/feature-store.md)| Feature Engineering in Unity Catalog (standard `FeatureLookup` API): `FeatureEngineeringClient`, `create_table` with `timeseries_column`, `FeatureLookup` with point-in-time joins, `fe.log_model` with lineage, `fe.score_batch` (replaces `spark_udf` for FE models), and Lakebase online store via `publish_table`. Requires `databricks-feature-engineering>=0.16.0`. |
274
+
|[references/feature-views.md](references/feature-views.md)| Feature Views (declarative Feature Engineering, Public Preview): `create_feature` over `DeltaTableSource`, `RollingWindow`/`SlidingWindow`/`TumblingWindow` aggregations, `materialize_features` (offline + online), streaming features off Kafka via `create_stream`, point-in-time training sets, and the Feature Serving Endpoint. Requires `databricks-feature-engineering>=0.16.0`. |
0 commit comments