The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Drop the nonexistent schema from Metabot's Sample Database examples (#82958)
Andrei Simionescue6dcb849bea7
diff --git a/resources/metabot/prompts/shared/prompt_snippets/mbql-shape.selmer b/resources/metabot/prompts/shared/prompt_snippets/mbql-shape.selmerindex ad8bc3f7c44..af0ea0f5c02 100644--- a/resources/metabot/prompts/shared/prompt_snippets/mbql-shape.selmer+++ b/resources/metabot/prompts/shared/prompt_snippets/mbql-shape.selmer@@ -17,9 +17,9 @@ Questions of the form *"which / who / what has the most / highest / slowest / la```json{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],- "aggregation": [["sum", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]]]],- "breakout": [["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "PRODUCT_ID"]]],+ "source-table": ["Sample Database", null, "ORDERS"],+ "aggregation": [["sum", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]]]],+ "breakout": [["field", {}, ["Sample Database", null, "ORDERS", "PRODUCT_ID"]]],"order-by": [["desc", {}, ["aggregation", {}, 0]]],"limit": 1}```diff --git a/resources/metabot/prompts/tools/construct_notebook_query.md b/resources/metabot/prompts/tools/construct_notebook_query.mdindex 05e6b12984b..0237812a1c4 100644--- a/resources/metabot/prompts/tools/construct_notebook_query.md+++ b/resources/metabot/prompts/tools/construct_notebook_query.md@@ -13,10 +13,10 @@ Return:```json{"lib/type": "mbql/query","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["count", {}]],"breakout": [["field", {"temporal-unit": "month"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]}]}+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]}]}```Every clause is `["op", {}, ...args]` with a mandatory `{}` options map at position 1; every field reference uses a 4-segment portable FK in the last slot. These are the two most-violated rules.@@ -48,7 +48,7 @@ There is no top-level `database:` field in the LLM contract — the database is["field", {}, ["<db-name>", "<schema-or-null>", "<table-name>", "<field-name>"]]```-The third slot is the **portable field FK** — a 4+ element string array. Schemaless databases (MongoDB, etc.) use `null` in the schema slot: `["Mongo", null, "orders", "created_at"]`. JSON-unfolded fields append extra segments: `["DB", "SCH", "TBL", "PARENT", "CHILD"]`.+The third slot is the **portable field FK** — a 4+ element string array. Schemaless databases (the Sample Database, MongoDB, etc.) use `null` in the schema slot: `["Mongo", null, "orders", "created_at"]`. JSON-unfolded fields append extra segments: `["DB", "SCH", "TBL", "PARENT", "CHILD"]`.Inside later stages, refer to a column produced by the previous stage by **string name** instead of a portable FK: `["field", {}, "count"]`, `["field", {}, "PRODUCT_ID"]`.@@ -68,14 +68,14 @@ Filter (comparison + boolean combination):```json"filters": [["and", {},- [">", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]], 100],- ["=", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "STATUS"]], "paid"]]]+ [">", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]], 100],+ ["<=", {}, ["field", {}, ["Sample Database", null, "ORDERS", "QUANTITY"]], 5]]]```Aggregation (on a field, plus `count`):```json-"aggregation": [["sum", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]]],+"aggregation": [["sum", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]]],["count", {}]]```@@ -83,13 +83,13 @@ Breakout with temporal bucket:```json"breakout": [["field", {"temporal-unit": "month"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]```Order by — direction wraps a ref; works on field refs or aggregation refs:```json-"order-by": [["desc", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]],+"order-by": [["desc", {}, ["field", {}, ["Sample Database", null, "ORDERS", "CREATED_AT"]]],["desc", {}, ["aggregation", {}, 0]]]```@@ -110,8 +110,8 @@ Define custom columns inside a stage using `expressions` and reference by name w```json"expressions": {"Subtotal": ["+", {},- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]],- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TAX"]]]+ ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]],+ ["field", {}, ["Sample Database", null, "ORDERS", "TAX"]]]},"aggregation": [["sum", {}, ["expression", {}, "Subtotal"]]]```@@ -125,14 +125,14 @@ The sequential form `[["expression", {}, "Name", expr], ...]` is also accepted a"alias": "Products","strategy": "left-join","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "PRODUCTS"]}],+ "source-table": ["Sample Database", null, "PRODUCTS"]}],"conditions": [["=", {},- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "PRODUCT_ID"]],+ ["field", {}, ["Sample Database", null, "ORDERS", "PRODUCT_ID"]],["field", {"join-alias": "Products"},- ["Sample Database", "PUBLIC", "PRODUCTS", "ID"]]]]+ ["Sample Database", null, "PRODUCTS", "ID"]]]]}],"breakout": [["field", {"join-alias": "Products"},- ["Sample Database", "PUBLIC", "PRODUCTS", "CATEGORY"]]]+ ["Sample Database", null, "PRODUCTS", "CATEGORY"]]]```- `alias` is a free-choice string; use it consistently in conditions, breakout, aggregation, order-by.@@ -145,9 +145,9 @@ The sequential form `[["expression", {}, "Name", expr], ...]` is also accepted aReference a field on a related table directly — when the source has exactly one FK to that target, the tool auto-fills `source-field` and performs the implicit join:```json-"source-table": ["Sample Database", "PUBLIC", "ORDERS"],+"source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["count", {}]],-"breakout": [["field", {}, ["Sample Database", "PUBLIC", "PRODUCTS", "CATEGORY"]]]+"breakout": [["field", {}, ["Sample Database", null, "PRODUCTS", "CATEGORY"]]]```- **Multiple FKs** to the target → `:ambiguous-fk` lists them. Retry with explicit `{"source-field": ["DB", "SCH", "SRC", "FK_COL"]}` on the field.@@ -167,9 +167,9 @@ Post-aggregation filter — count orders per product, keep only those with > 10:```json"stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["count", {}]],- "breakout": [["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "PRODUCT_ID"]]]},+ "breakout": [["field", {}, ["Sample Database", null, "ORDERS", "PRODUCT_ID"]]]},{"lib/type": "mbql.stage/mbql","filters": [[">", {}, ["field", {}, "count"], 10]]}]@@ -180,10 +180,10 @@ Re-aggregate — average daily total by month:```json"stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],- "aggregation": [["sum", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]]]],+ "source-table": ["Sample Database", null, "ORDERS"],+ "aggregation": [["sum", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]]]],"breakout": [["field", {"temporal-unit": "day"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]},+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]},{"lib/type": "mbql.stage/mbql","aggregation": [["avg", {}, ["field", {}, "sum"]]],"breakout": [["field", {"temporal-unit": "month"}, ["field", {}, "CREATED_AT"]]]}diff --git a/resources/metabot/skills/construct-notebook-query-advanced.md b/resources/metabot/skills/construct-notebook-query-advanced.mdindex 1270d3d884d..416bde0b7a4 100644--- a/resources/metabot/skills/construct-notebook-query-advanced.md+++ b/resources/metabot/skills/construct-notebook-query-advanced.md@@ -24,8 +24,8 @@ Define custom columns inside a stage using `expressions` and reference by name w```json"expressions": {"Subtotal": ["+", {},- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]],- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TAX"]]]+ ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]],+ ["field", {}, ["Sample Database", null, "ORDERS", "TAX"]]]},"aggregation": [["sum", {}, ["expression", {}, "Subtotal"]]]```@@ -39,14 +39,14 @@ A sequential form is also accepted, but the name must live in the defining claus"alias": "Products","strategy": "left-join","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "PRODUCTS"]}],+ "source-table": ["Sample Database", null, "PRODUCTS"]}],"conditions": [["=", {},- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "PRODUCT_ID"]],+ ["field", {}, ["Sample Database", null, "ORDERS", "PRODUCT_ID"]],["field", {"join-alias": "Products"},- ["Sample Database", "PUBLIC", "PRODUCTS", "ID"]]]]+ ["Sample Database", null, "PRODUCTS", "ID"]]]]}],"breakout": [["field", {"join-alias": "Products"},- ["Sample Database", "PUBLIC", "PRODUCTS", "CATEGORY"]]]+ ["Sample Database", null, "PRODUCTS", "CATEGORY"]]]```- `alias` is a free-choice string; use it consistently in conditions, breakout, aggregation, order-by.@@ -59,9 +59,9 @@ A sequential form is also accepted, but the name must live in the defining clausReference a field on a related table directly — when the source has exactly one FK to that target, the tool auto-fills `source-field` and performs the implicit join:```json-"source-table": ["Sample Database", "PUBLIC", "ORDERS"],+"source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["count", {}]],-"breakout": [["field", {}, ["Sample Database", "PUBLIC", "PRODUCTS", "CATEGORY"]]]+"breakout": [["field", {}, ["Sample Database", null, "PRODUCTS", "CATEGORY"]]]```- **Multiple FKs** to the target → `:ambiguous-fk` lists them. Retry with explicit `{"source-field": ["DB", "SCH", "SRC", "FK_COL"]}` on the field.@@ -81,9 +81,9 @@ Post-aggregation filter — count orders per product, keep only those with > 10:```json"stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["count", {}]],- "breakout": [["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "PRODUCT_ID"]]]},+ "breakout": [["field", {}, ["Sample Database", null, "ORDERS", "PRODUCT_ID"]]]},{"lib/type": "mbql.stage/mbql","filters": [[">", {}, ["field", {}, "count"], 10]]}]@@ -94,10 +94,10 @@ Re-aggregate — average daily total by month:```json"stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],- "aggregation": [["sum", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]]]],+ "source-table": ["Sample Database", null, "ORDERS"],+ "aggregation": [["sum", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]]]],"breakout": [["field", {"temporal-unit": "day"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]},+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]},{"lib/type": "mbql.stage/mbql","aggregation": [["avg", {}, ["field", {}, "sum"]]],"breakout": [["field", {"temporal-unit": "month"}, ["field", {}, "CREATED_AT"]]]}@@ -117,13 +117,13 @@ A rate like **open rate**, **bounce rate**, **conversion rate**, or **% of total```json{"lib/type": "mbql/query","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["/", {},["count-where", {},- ["<", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]], 50]],+ ["<", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]], 50]],["count", {}]]],"breakout": [["field", {"temporal-unit": "month"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]}]}+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]}]}```**Two stages** — use this when you also want the numerator and denominator as their own columns, or when the ratio needs further post-aggregation work. Compute them as separate aggregations in **stage 1**, then divide in **stage 2**.@@ -134,12 +134,12 @@ Worked example — share of small orders per month (`count of orders under $50{"lib/type": "mbql/query","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [- ["count-where", {}, ["<", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]], 50]],+ ["count-where", {}, ["<", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]], 50]],["count", {}]],"breakout": [["field", {"temporal-unit": "month"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]},+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]},{"lib/type": "mbql.stage/mbql","expressions": {"Small Order Rate": ["/", {}, ["field", {}, "count_where"], ["field", {}, "count"]]},@@ -178,9 +178,9 @@ A metric is a pre-defined aggregation attached to a base table. To use one:```json{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"filters": [[">", {}, ["field", {},- ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]], 0]],+ ["Sample Database", null, "ORDERS", "TOTAL"]], 0]],"aggregation": [["metric", {}, "aB3cD4eF5gH6iJ7kL8mN9"]]}```@@ -192,18 +192,18 @@ To group a metric by a field that lives on a **different** table, add an explici```json{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["metric", {}, "aB3cD4eF5gH6iJ7kL8mN9"]],"joins": [{"alias": "Products","strategy": "left-join","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "PRODUCTS"]}],+ "source-table": ["Sample Database", null, "PRODUCTS"]}],"conditions": [["=", {},- ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "PRODUCT_ID"]],+ ["field", {}, ["Sample Database", null, "ORDERS", "PRODUCT_ID"]],["field", {"join-alias": "Products"},- ["Sample Database", "PUBLIC", "PRODUCTS", "ID"]]]]}],+ ["Sample Database", null, "PRODUCTS", "ID"]]]]}],"breakout": [["field", {"join-alias": "Products"},- ["Sample Database", "PUBLIC", "PRODUCTS", "CATEGORY"]]]}+ ["Sample Database", null, "PRODUCTS", "CATEGORY"]]]}```When the breakout dimension lives on the metric's **own** base table, no join is needed — just break out on a portable FK as in the example above.diff --git a/resources/metabot/skills/construct-notebook-query-core.md b/resources/metabot/skills/construct-notebook-query-core.mdindex 7d92e70ae9e..f10c0d38a5b 100644--- a/resources/metabot/skills/construct-notebook-query-core.md+++ b/resources/metabot/skills/construct-notebook-query-core.md@@ -26,10 +26,10 @@ Return:```json{"lib/type": "mbql/query","stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],+ "source-table": ["Sample Database", null, "ORDERS"],"aggregation": [["count", {}]],"breakout": [["field", {"temporal-unit": "month"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]}]}+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]}]}```Every clause is `["op", {}, ...args]` with a mandatory `{}` options map at position 1; every field reference uses a 4-segment portable FK in the last slot. These are the two most-violated rules.@@ -61,7 +61,7 @@ There is no top-level `database:` field in the LLM contract — the database is["field", {}, ["<db-name>", "<schema-or-null>", "<table-name>", "<field-name>"]]```-The third slot is the **portable field FK** — a 4+ element string array. Schemaless databases (MongoDB, etc.) use `null` in the schema slot: `["Mongo", null, "orders", "created_at"]`. JSON-unfolded fields append extra segments: `["DB", "SCH", "TBL", "PARENT", "CHILD"]`.+The third slot is the **portable field FK** — a 4+ element string array. Schemaless databases (the Sample Database, MongoDB, etc.) use `null` in the schema slot: `["Mongo", null, "orders", "created_at"]`. JSON-unfolded fields append extra segments: `["DB", "SCH", "TBL", "PARENT", "CHILD"]`.Inside later stages, refer to a column produced by the previous stage by **string name** instead of a portable FK: `["field", {}, "count"]`, `["field", {}, "PRODUCT_ID"]`.@@ -81,14 +81,14 @@ Filter (comparison + boolean combination):```json"filters": [["and", {},- [">", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]], 100],- ["=", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "STATUS"]], "paid"]]]+ [">", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]], 100],+ ["<=", {}, ["field", {}, ["Sample Database", null, "ORDERS", "QUANTITY"]], 5]]]```Aggregation (on a field, plus `count`):```json-"aggregation": [["sum", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]]],+"aggregation": [["sum", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]]],["count", {}]]```@@ -96,13 +96,13 @@ Breakout with temporal bucket:```json"breakout": [["field", {"temporal-unit": "month"},- ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]]+ ["Sample Database", null, "ORDERS", "CREATED_AT"]]]```Order by — direction wraps a ref; works on field refs or aggregation refs:```json-"order-by": [["desc", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "CREATED_AT"]]],+"order-by": [["desc", {}, ["field", {}, ["Sample Database", null, "ORDERS", "CREATED_AT"]]],["desc", {}, ["aggregation", {}, 0]]]```diff --git a/resources/metabot/skills/read-resource.md b/resources/metabot/skills/read-resource.mdindex 8009f34a2f5..15d9f386842 100644--- a/resources/metabot/skills/read-resource.md+++ b/resources/metabot/skills/read-resource.md@@ -54,7 +54,8 @@ You can request multiple resources in one call by providing a list of URIs (max- `metabase://database/{id}/schemas/{schemaName}/tables` — tables in a specific schema**Examples:**-- Want to see warehouse layout before writing SQL? → `metabase://database/1/schemas` then `metabase://database/1/schemas/PUBLIC/tables`+- Want to see warehouse layout before writing SQL? → `metabase://database/2/schemas` then `metabase://database/2/schemas/public/tables`+- Database without schemas, like the Sample Database (its `/schemas` list is empty)? → `metabase://database/1/tables`- Want curated models in a specific warehouse? → `metabase://database/1/models`**Best Practices:**diff --git a/src/metabase/agent_api/api.clj b/src/metabase/agent_api/api.cljindex 28039648505..40ed93817cf 100644--- a/src/metabase/agent_api/api.clj+++ b/src/metabase/agent_api/api.clj@@ -287,10 +287,10 @@"```\n""{\"query\": {\"lib/type\": \"mbql/query\",\n"" \"stages\": [{\"lib/type\": \"mbql.stage/mbql\",\n"- " \"source-table\": [\"Sample Database\", \"PUBLIC\", \"ORDERS\"],\n"+ " \"source-table\": [\"Sample Database\", null, \"ORDERS\"],\n"" \"aggregation\": [[\"count\", {}]],\n"" \"breakout\": [[\"field\", {\"temporal-unit\": \"month\"},\n"- " [\"Sample Database\", \"PUBLIC\", \"ORDERS\", \"CREATED_AT\"]]]}]}}\n"+ " [\"Sample Database\", null, \"ORDERS\", \"CREATED_AT\"]]]}]}}\n""```\n""\n""Common pitfalls: (1) forgetting the `{}` options map; (2) writing numeric "diff --git a/src/metabase/agent_api/reference.md b/src/metabase/agent_api/reference.mdindex 92400e8f79f..a5db24abbc4 100644--- a/src/metabase/agent_api/reference.md+++ b/src/metabase/agent_api/reference.md@@ -206,7 +206,7 @@ Response:"display_name": "Orders","description": "All customer orders","database_id": 1,- "database_schema": "PUBLIC",+ "database_schema": null,"verified": false},{@@ -256,9 +256,9 @@ Minimal example:"stages": [{"lib/type": "mbql.stage/mbql",- "source-table": ["Sample Database", "PUBLIC", "ORDERS"],- "aggregation": [["sum", {}, ["field", {}, ["Sample Database", "PUBLIC", "ORDERS", "TOTAL"]]]],- "breakout": [["field", {}, ["Sample Database", "PUBLIC", "PEOPLE", "STATE"]]],+ "source-table": ["Sample Database", null, "ORDERS"],+ "aggregation": [["sum", {}, ["field", {}, ["Sample Database", null, "ORDERS", "TOTAL"]]]],+ "breakout": [["field", {}, ["Sample Database", null, "PEOPLE", "STATE"]]],"limit": 100}]diff --git a/src/metabase/metabot/tools/construct.clj b/src/metabase/metabot/tools/construct.cljindex 8c399615f9a..2c80b90cf49 100644--- a/src/metabase/metabot/tools/construct.clj+++ b/src/metabase/metabot/tools/construct.clj@@ -54,9 +54,9 @@"(possibly empty) options map at position 1, and every field reference is `[\"field\", {}, ""[\"<db>\", \"<schema>\", \"<table>\", \"<field>\"]]`. Minimal example — count of orders by ""month: `{\"lib/type\": \"mbql/query\", \"stages\": [{\"lib/type\": \"mbql.stage/mbql\", "- "\"source-table\": [\"Sample Database\", \"PUBLIC\", \"ORDERS\"], \"aggregation\": "+ "\"source-table\": [\"Sample Database\", null, \"ORDERS\"], \"aggregation\": ""[[\"count\", {}]], \"breakout\": [[\"field\", {\"temporal-unit\": \"month\"}, "- "[\"Sample Database\", \"PUBLIC\", \"ORDERS\", \"CREATED_AT\"]]]}]}`. Load the "+ "[\"Sample Database\", null, \"ORDERS\", \"CREATED_AT\"]]]}]}`. Load the ""`construct-notebook-query-*` skills for the full operator catalog, joins, expressions, ""and multi-stage rules."):required ["lib/type" "stages"]@@ -74,7 +74,7 @@"source-table" {:type "array":minItems 3:maxItems 3- :items {:type "string"}+ :items {}:description "Portable FK `[<db-name>, <schema-or-null>, <table-name>]`."}"source-card" {:type "string":description "entity_id of a saved question/model used as the source."}diff --git a/test/metabase/metabot/agent/prompts_test.clj b/test/metabase/metabot/agent/prompts_test.cljindex 81ff091669b..f86a89eb4b8 100644--- a/test/metabase/metabot/agent/prompts_test.clj+++ b/test/metabase/metabot/agent/prompts_test.clj@@ -3,11 +3,14 @@[clojure.java.io :as io][clojure.string :as str][clojure.test :refer :all]+ [metabase.agent-api.api][metabase.api-scope.core :as api-scope]+ [metabase.api.macros :as api.macros][metabase.metabot.agent.profiles :as profiles][metabase.metabot.agent.prompts :as prompts][metabase.metabot.scope :as scope]- [metabase.metabot.skills :as skills]))+ [metabase.metabot.skills :as skills]+ [metabase.metabot.tools.construct :as construct]))(deftest ^:parallel load-system-prompt-template-test(testing "loads internal.selmer template"@@ -34,6 +37,19 @@(is (str/includes? prompt "Sample Database"))(is (not (re-find #"\[Sample\s*," prompt))))))+(deftest ^:parallel sample-database-examples-use-a-null-schema-test+ (doseq [[source text] {"construct_notebook_query.md" (slurp (io/resource "metabot/prompts/tools/construct_notebook_query.md"))+ "construct-notebook-query-core.md" (slurp (io/resource "metabot/skills/construct-notebook-query-core.md"))+ "construct-notebook-query-advanced.md" (slurp (io/resource "metabot/skills/construct-notebook-query-advanced.md"))+ "mbql-shape.selmer" (slurp (io/resource "metabot/prompts/shared/prompt_snippets/mbql-shape.selmer"))+ "construct_notebook_query tool" (:description @#'construct/construct-notebook-query-json-schema)+ "Agent API construct_query tool" (-> (api.macros/find-route 'metabase.agent-api.api :post "/v2/construct-query")+ (get-in [:form :metadata :tool :description]))+ "Agent API reference.md" (slurp (io/resource "metabase/agent_api/reference.md"))}]+ (testing source+ (is (= #{"null"}+ (set (map second (re-seq #"\"Sample Database\",\s*([^,\s]+)" text))))))))+(deftest ^:parallel render-system-prompt-test(testing "renders template with variables"(let [template "Hello {{name}}, today is {{day}}"