:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(mcp): unbreak view-create tool (#59200)
Jovan Sakovicde7a715a6132
diff --git a/products/data_warehouse/backend/api/saved_query.py b/products/data_warehouse/backend/api/saved_query.pyindex b66e07ee9cb1..b79914d20a13 100644--- a/products/data_warehouse/backend/api/saved_query.py+++ b/products/data_warehouse/backend/api/saved_query.py@@ -190,8 +190,24 @@ class DataWarehouseSavedQueryMinimalSerializer(class DataWarehouseSavedQuerySerializer(DataWarehouseSavedQuerySerializerMixin, UserAccessControlSerializerMixin, serializers.ModelSerializer):+ @extend_schema_field(+ {+ "type": "object",+ "properties": {+ "kind": {"type": "string", "enum": ["HogQLQuery"], "default": "HogQLQuery"},+ "query": {"type": "string"},+ },+ "required": ["query"],+ }+ )+ class QueryDefinitionField(serializers.JSONField):+ pass+created_by = UserBasicSerializer(read_only=True)columns = serializers.SerializerMethodField(read_only=True)+ query = QueryDefinitionField(+ help_text='HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}',+ )sync_frequency = serializers.SerializerMethodField()latest_history_id = serializers.SerializerMethodField(read_only=True)last_run_at = serializers.SerializerMethodField(read_only=True)@@ -273,9 +289,6 @@ class DataWarehouseSavedQuerySerializer("name": {"help_text": "Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.",},- "query": {- "help_text": 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"}',- },}@extend_schema_field(serializers.IntegerField(allow_null=True))@@ -531,6 +544,19 @@ class DataWarehouseSavedQuerySerializer(return viewdef validate_query(self, query):+ if not isinstance(query, dict):+ raise exceptions.ValidationError(+ detail=(+ 'Query must be a JSON object with a "query" key, '+ f"got {type(query).__name__}. "+ 'Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'+ )+ )+ if not isinstance(query.get("query"), str) or not query["query"].strip():+ raise exceptions.ValidationError(+ detail='Query object must contain a non-empty "query" key with the SQL string.'+ )+team_id = self.context["team_id"]user = self.context["request"].userdiff --git a/products/data_warehouse/backend/api/test/test_saved_query.py b/products/data_warehouse/backend/api/test/test_saved_query.pyindex e8d6bd83b9dc..54cf90a368f7 100644--- a/products/data_warehouse/backend/api/test/test_saved_query.py+++ b/products/data_warehouse/backend/api/test/test_saved_query.py@@ -297,6 +297,30 @@ class TestSavedQuery(APIBaseTest):)self.assertEqual(response.status_code, 400, response.content)+ def test_create_with_query_as_string_returns_validation_error(self):+ response = self.client.post(+ f"/api/environments/{self.team.id}/warehouse_saved_queries/",+ {+ "name": "event_view_bad_payload",+ "query": '{"kind": "HogQLQuery", "query": "SELECT 1"}',+ },+ format="json",+ )+ assert response.status_code == 400, response.content+ response_json = response.json()+ assert "JSON object" in response_json.get("detail", "")++ def test_create_with_query_missing_query_key_returns_validation_error(self):+ response = self.client.post(+ f"/api/environments/{self.team.id}/warehouse_saved_queries/",+ {+ "name": "event_view_missing_key",+ "query": {"kind": "HogQLQuery"},+ },+ format="json",+ )+ assert response.status_code == 400, response.content+def test_create_using_placeholders(self):response = self.client.post(f"/api/environments/{self.team.id}/warehouse_saved_queries/",diff --git a/products/data_warehouse/frontend/generated/api.schemas.ts b/products/data_warehouse/frontend/generated/api.schemas.tsindex e67cb60b902c..ff041674e441 100644--- a/products/data_warehouse/frontend/generated/api.schemas.ts+++ b/products/data_warehouse/frontend/generated/api.schemas.ts@@ -1581,6 +1581,21 @@ export interface PaginatedDataWarehouseSavedQueryMinimalListApi {results: DataWarehouseSavedQueryMinimalApi[]}+export type DataWarehouseSavedQueryApiQueryKind =+ (typeof DataWarehouseSavedQueryApiQueryKind)[keyof typeof DataWarehouseSavedQueryApiQueryKind]++export const DataWarehouseSavedQueryApiQueryKind = {+ HogQLQuery: 'HogQLQuery',+} as const++/**+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}+ */+export type DataWarehouseSavedQueryApiQuery = {+ kind?: DataWarehouseSavedQueryApiQueryKind+ query: string+}+export type DataWarehouseSavedQueryApiColumnsItem = { [key: string]: unknown }/**@@ -1597,8 +1612,8 @@ export interface DataWarehouseSavedQueryApi {* @maxLength 128*/name: string- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"} */- query?: unknown+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */+ query: DataWarehouseSavedQueryApiQueryreadonly created_by: UserBasicApireadonly created_at: string/** @nullable */@@ -1667,6 +1682,21 @@ export interface DataWarehouseSavedQueryApi {readonly user_access_level: string | null}+export type PatchedDataWarehouseSavedQueryApiQueryKind =+ (typeof PatchedDataWarehouseSavedQueryApiQueryKind)[keyof typeof PatchedDataWarehouseSavedQueryApiQueryKind]++export const PatchedDataWarehouseSavedQueryApiQueryKind = {+ HogQLQuery: 'HogQLQuery',+} as const++/**+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}+ */+export type PatchedDataWarehouseSavedQueryApiQuery = {+ kind?: PatchedDataWarehouseSavedQueryApiQueryKind+ query: string+}+export type PatchedDataWarehouseSavedQueryApiColumnsItem = { [key: string]: unknown }/**@@ -1683,8 +1713,8 @@ export interface PatchedDataWarehouseSavedQueryApi {* @maxLength 128*/name?: string- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"} */- query?: unknown+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */+ query?: PatchedDataWarehouseSavedQueryApiQueryreadonly created_by?: UserBasicApireadonly created_at?: string/** @nullable */diff --git a/products/data_warehouse/frontend/generated/api.zod.ts b/products/data_warehouse/frontend/generated/api.zod.tsindex fb3a4ab2e811..657c35774e19 100644--- a/products/data_warehouse/frontend/generated/api.zod.ts+++ b/products/data_warehouse/frontend/generated/api.zod.ts@@ -1313,6 +1313,8 @@ export const QueryTabStatePartialUpdateBody = /* @__PURE__ */ zod.object({*/export const warehouseSavedQueriesCreateBodyNameMax = 128+export const warehouseSavedQueriesCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1323,10 +1325,12 @@ export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1352,6 +1356,8 @@ export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod*/export const warehouseSavedQueriesUpdateBodyNameMax = 128+export const warehouseSavedQueriesUpdateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesUpdateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1362,10 +1368,12 @@ export const WarehouseSavedQueriesUpdateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesUpdateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1391,6 +1399,8 @@ export const WarehouseSavedQueriesUpdateBody = /* @__PURE__ */ zod*/export const warehouseSavedQueriesPartialUpdateBodyNameMax = 128+export const warehouseSavedQueriesPartialUpdateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesPartialUpdateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1402,10 +1412,13 @@ export const WarehouseSavedQueriesPartialUpdateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesPartialUpdateBodyQueryKindDefault),+ query: zod.string(),+ }).optional().describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1435,6 +1448,8 @@ ancestors beyond the root), we return an empty list.*/export const warehouseSavedQueriesAncestorsCreateBodyNameMax = 128+export const warehouseSavedQueriesAncestorsCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesAncestorsCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1445,10 +1460,12 @@ export const WarehouseSavedQueriesAncestorsCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesAncestorsCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1474,6 +1491,8 @@ export const WarehouseSavedQueriesAncestorsCreateBody = /* @__PURE__ */ zod*/export const warehouseSavedQueriesCancelCreateBodyNameMax = 128+export const warehouseSavedQueriesCancelCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesCancelCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1484,10 +1503,12 @@ export const WarehouseSavedQueriesCancelCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesCancelCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1517,6 +1538,8 @@ descendants further than a leaf), we return an empty list.*/export const warehouseSavedQueriesDescendantsCreateBodyNameMax = 128+export const warehouseSavedQueriesDescendantsCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesDescendantsCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1527,10 +1550,12 @@ export const WarehouseSavedQueriesDescendantsCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesDescendantsCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1556,6 +1581,8 @@ export const WarehouseSavedQueriesDescendantsCreateBody = /* @__PURE__ */ zod*/export const warehouseSavedQueriesMaterializeCreateBodyNameMax = 128+export const warehouseSavedQueriesMaterializeCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1566,10 +1593,12 @@ export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesMaterializeCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1596,6 +1625,8 @@ export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod*/export const warehouseSavedQueriesRevertMaterializationCreateBodyNameMax = 128+export const warehouseSavedQueriesRevertMaterializationCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1606,10 +1637,14 @@ export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod+ .enum(['HogQLQuery'])+ .default(warehouseSavedQueriesRevertMaterializationCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1635,6 +1670,8 @@ export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__*/export const warehouseSavedQueriesRunCreateBodyNameMax = 128+export const warehouseSavedQueriesRunCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesRunCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1645,10 +1682,12 @@ export const WarehouseSavedQueriesRunCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesRunCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()@@ -1677,6 +1716,8 @@ This endpoint is idempotent - calling it on already running or non-existent sche*/export const warehouseSavedQueriesResumeSchedulesCreateBodyNameMax = 128+export const warehouseSavedQueriesResumeSchedulesCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesResumeSchedulesCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1687,10 +1728,12 @@ export const WarehouseSavedQueriesResumeSchedulesCreateBody = /* @__PURE__ */ zo'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesResumeSchedulesCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT \* FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}'+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'),folder_id: zod.uuid()diff --git a/products/data_warehouse/mcp/tools.yaml b/products/data_warehouse/mcp/tools.yamlindex cd349bc1e0ac..9b6bfc896d7b 100644--- a/products/data_warehouse/mcp/tools.yaml+++ b/products/data_warehouse/mcp/tools.yaml@@ -562,10 +562,6 @@ tools:description:Unique name for the view. Used as the table name in HogQL queries. Must not conflict with existing tablenames.- query:- description:- 'HogQL query definition as a JSON object. Must contain a "query" key with the SQL string. Example:- {"query": "SELECT * FROM events LIMIT 100"}'view-delete:operation: warehouse_saved_queries_destroyenabled: true@@ -704,10 +700,6 @@ tools:description:Unique name for the view. Used as the table name in HogQL queries. Must not conflict with existing tablenames.- query:- description:- 'HogQL query definition as a JSON object. Must contain a "query" key with the SQL string. Example:- {"query": "SELECT * FROM events LIMIT 100"}'edited_history_id:description:Required when updating the query field. Get this from latest_history_id on the retrieve response. Used fordiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex a925a12692ae..ad9c86021f44 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -11058,6 +11058,21 @@ export namespace Schemas {readonly updated_at: string | null;}+ export type DataWarehouseSavedQueryQueryKind = typeof DataWarehouseSavedQueryQueryKind[keyof typeof DataWarehouseSavedQueryQueryKind];+++ export const DataWarehouseSavedQueryQueryKind = {+ HogQLQuery: 'HogQLQuery',+ } as const;++ /**+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}+ */+ export type DataWarehouseSavedQueryQuery = {+ kind?: DataWarehouseSavedQueryQueryKind;+ query: string;+ };+export type DataWarehouseSavedQueryColumnsItem = { [key: string]: unknown };/**@@ -11106,8 +11121,8 @@ export namespace Schemas {* @maxLength 128*/name: string;- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"} */- query?: unknown;+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */+ query: DataWarehouseSavedQueryQuery;readonly created_by: UserBasic;readonly created_at: string;/** @nullable */@@ -26274,6 +26289,21 @@ export namespace Schemas {readonly created_by?: UserBasic;}+ export type PatchedDataWarehouseSavedQueryQueryKind = typeof PatchedDataWarehouseSavedQueryQueryKind[keyof typeof PatchedDataWarehouseSavedQueryQueryKind];+++ export const PatchedDataWarehouseSavedQueryQueryKind = {+ HogQLQuery: 'HogQLQuery',+ } as const;++ /**+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}+ */+ export type PatchedDataWarehouseSavedQueryQuery = {+ kind?: PatchedDataWarehouseSavedQueryQueryKind;+ query: string;+ };+export type PatchedDataWarehouseSavedQueryColumnsItem = { [key: string]: unknown };/**@@ -26290,8 +26320,8 @@ export namespace Schemas {* @maxLength 128*/name?: string;- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"} */- query?: unknown;+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */+ query?: PatchedDataWarehouseSavedQueryQuery;readonly created_by?: UserBasic;readonly created_at?: string;/** @nullable */diff --git a/services/mcp/src/generated/data_warehouse/api.ts b/services/mcp/src/generated/data_warehouse/api.tsindex 5a5a6b26da13..2c4ab616ca74 100644--- a/services/mcp/src/generated/data_warehouse/api.ts+++ b/services/mcp/src/generated/data_warehouse/api.ts@@ -1020,6 +1020,8 @@ export const WarehouseSavedQueriesCreateParams = /* @__PURE__ */ zod.object({export const warehouseSavedQueriesCreateBodyNameMax = 128+export const warehouseSavedQueriesCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod.object({name: zod@@ -1029,10 +1031,12 @@ export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"}'+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'),folder_id: zod.uuid()@@ -1071,6 +1075,8 @@ export const WarehouseSavedQueriesPartialUpdateParams = /* @__PURE__ */ zod.objeexport const warehouseSavedQueriesPartialUpdateBodyNameMax = 128+export const warehouseSavedQueriesPartialUpdateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesPartialUpdateBody = /* @__PURE__ */ zod.object({name: zod@@ -1081,10 +1087,13 @@ export const WarehouseSavedQueriesPartialUpdateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesPartialUpdateBodyQueryKindDefault),+ query: zod.string(),+ }).optional().describe(- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"}'+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'),folder_id: zod.uuid()@@ -1127,6 +1136,8 @@ export const WarehouseSavedQueriesMaterializeCreateParams = /* @__PURE__ */ zod.export const warehouseSavedQueriesMaterializeCreateBodyNameMax = 128+export const warehouseSavedQueriesMaterializeCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1137,10 +1148,12 @@ export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesMaterializeCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"}'+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'),folder_id: zod.uuid()@@ -1176,6 +1189,8 @@ export const WarehouseSavedQueriesRevertMaterializationCreateParams = /* @__PUREexport const warehouseSavedQueriesRevertMaterializationCreateBodyNameMax = 128+export const warehouseSavedQueriesRevertMaterializationCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1186,10 +1201,14 @@ export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod+ .enum(['HogQLQuery'])+ .default(warehouseSavedQueriesRevertMaterializationCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"}'+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'),folder_id: zod.uuid()@@ -1224,6 +1243,8 @@ export const WarehouseSavedQueriesRunCreateParams = /* @__PURE__ */ zod.object({export const warehouseSavedQueriesRunCreateBodyNameMax = 128+export const warehouseSavedQueriesRunCreateBodyQueryKindDefault = `HogQLQuery`+export const WarehouseSavedQueriesRunCreateBody = /* @__PURE__ */ zod.object({deleted: zod.boolean().nullish(),@@ -1234,10 +1255,12 @@ export const WarehouseSavedQueriesRunCreateBody = /* @__PURE__ */ zod'Unique name for the view. Used as the table name in HogQL queries and the node name in the data modeling Node.'),query: zod- .unknown()- .optional()+ .object({+ kind: zod.enum(['HogQLQuery']).default(warehouseSavedQueriesRunCreateBodyQueryKindDefault),+ query: zod.string(),+ }).describe(- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key containing the query type. Example: {"query": "SELECT * FROM events LIMIT 100", "kind": "HogQLQuery"}'+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'),folder_id: zod.uuid()diff --git a/services/mcp/src/tools/generated/data_warehouse.ts b/services/mcp/src/tools/generated/data_warehouse.tsindex 4d0fc9ab2593..9090a88271e9 100644--- a/services/mcp/src/tools/generated/data_warehouse.ts+++ b/services/mcp/src/tools/generated/data_warehouse.ts@@ -813,9 +813,6 @@ const ViewCreateSchema = WarehouseSavedQueriesCreateBody.extend({name: WarehouseSavedQueriesCreateBody.shape['name'].describe('Unique name for the view. Used as the table name in HogQL queries. Must not conflict with existing table names.'),- query: WarehouseSavedQueriesCreateBody.shape['query'].describe(- 'HogQL query definition as a JSON object. Must contain a "query" key with the SQL string. Example: {"query": "SELECT * FROM events LIMIT 100"}'- ),})const viewCreate = (): ToolBase<typeof ViewCreateSchema, WithPostHogUrl<Schemas.DataWarehouseSavedQuery>> => ({@@ -1066,9 +1063,6 @@ const ViewUpdateSchema = WarehouseSavedQueriesPartialUpdateParams.omit({ projectname: WarehouseSavedQueriesPartialUpdateBody.shape['name'].describe('Unique name for the view. Used as the table name in HogQL queries. Must not conflict with existing table names.'),- query: WarehouseSavedQueriesPartialUpdateBody.shape['query'].describe(- 'HogQL query definition as a JSON object. Must contain a "query" key with the SQL string. Example: {"query": "SELECT * FROM events LIMIT 100"}'- ),edited_history_id: WarehouseSavedQueriesPartialUpdateBody.shape['edited_history_id'].describe('Required when updating the query field. Get this from latest_history_id on the retrieve response. Used for optimistic concurrency control.'),diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-create.jsonindex fe0ef6cfb8a9..351f211ac801 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-create.json@@ -37,9 +37,21 @@"type": "string"},"query": {- "description": "HogQL query definition as a JSON object. Must contain a \"query\" key with the SQL string. Example: {\"query\": \"SELECT * FROM events LIMIT 100\"}"+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",+ "properties": {+ "kind": {+ "default": "HogQLQuery",+ "enum": ["HogQLQuery"],+ "type": "string"+ },+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"}},- "required": ["name"],+ "required": ["name", "query"],"type": "object"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-materialize.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-materialize.jsonindex 16b1ac7b75f2..948717df2fe9 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-materialize.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-materialize.json@@ -62,7 +62,19 @@"type": "string"},"query": {- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT * FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}"+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",+ "properties": {+ "kind": {+ "default": "HogQLQuery",+ "enum": ["HogQLQuery"],+ "type": "string"+ },+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"},"soft_update": {"anyOf": [@@ -76,6 +88,6 @@"description": "If true, skip column inference and validation. For saving drafts."}},- "required": ["id", "name"],+ "required": ["id", "name", "query"],"type": "object"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-run.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-run.jsonindex 16b1ac7b75f2..948717df2fe9 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-run.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-run.json@@ -62,7 +62,19 @@"type": "string"},"query": {- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT * FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}"+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",+ "properties": {+ "kind": {+ "default": "HogQLQuery",+ "enum": ["HogQLQuery"],+ "type": "string"+ },+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"},"soft_update": {"anyOf": [@@ -76,6 +88,6 @@"description": "If true, skip column inference and validation. For saving drafts."}},- "required": ["id", "name"],+ "required": ["id", "name", "query"],"type": "object"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-unmaterialize.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-unmaterialize.jsonindex 16b1ac7b75f2..948717df2fe9 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-unmaterialize.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-unmaterialize.json@@ -62,7 +62,19 @@"type": "string"},"query": {- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key containing the query type. Example: {\"query\": \"SELECT * FROM events LIMIT 100\", \"kind\": \"HogQLQuery\"}"+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",+ "properties": {+ "kind": {+ "default": "HogQLQuery",+ "enum": ["HogQLQuery"],+ "type": "string"+ },+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"},"soft_update": {"anyOf": [@@ -76,6 +88,6 @@"description": "If true, skip column inference and validation. For saving drafts."}},- "required": ["id", "name"],+ "required": ["id", "name", "query"],"type": "object"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-update.jsonindex db619fd28b9b..2152f8bee8f2 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/view-update.json@@ -52,7 +52,19 @@"type": "string"},"query": {- "description": "HogQL query definition as a JSON object. Must contain a \"query\" key with the SQL string. Example: {\"query\": \"SELECT * FROM events LIMIT 100\"}"+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",+ "properties": {+ "kind": {+ "default": "HogQLQuery",+ "enum": ["HogQLQuery"],+ "type": "string"+ },+ "query": {+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"}},"required": ["id"],