: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
feat(customer-analytics): accounts query runner (#60460)
Arthur Moreira de Deus208c887dda94
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex d8864f17b614..56ac0e340ec6 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -18,6 +18,152 @@],"type": "string"},+ "AccountsQuery": {+ "additionalProperties": false,+ "properties": {+ "accountExecutive": {+ "$ref": "#/definitions/AccountsRoleAssignmentFilter"+ },+ "accountOwner": {+ "$ref": "#/definitions/AccountsRoleAssignmentFilter"+ },+ "allRolesUnassigned": {+ "type": "boolean"+ },+ "csm": {+ "$ref": "#/definitions/AccountsRoleAssignmentFilter"+ },+ "kind": {+ "const": "AccountsQuery",+ "type": "string"+ },+ "limit": {+ "$ref": "#/definitions/integer"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "offset": {+ "$ref": "#/definitions/integer"+ },+ "orderBy": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "response": {+ "$ref": "#/definitions/AccountsQueryResponse"+ },+ "search": {+ "type": "string"+ },+ "select": {+ "items": {+ "$ref": "#/definitions/HogQLExpression"+ },+ "type": "array"+ },+ "tagNames": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "tags": {+ "$ref": "#/definitions/QueryLogTags"+ },+ "version": {+ "description": "version of the node, used for schema migrations",+ "type": "number"+ }+ },+ "required": ["kind"],+ "type": "object"+ },+ "AccountsQueryResponse": {+ "additionalProperties": false,+ "properties": {+ "columns": {+ "items": {},+ "type": "array"+ },+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hasMore": {+ "type": "boolean"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "kind": {+ "const": "AccountsQuery",+ "type": "string"+ },+ "limit": {+ "$ref": "#/definitions/integer"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "offset": {+ "$ref": "#/definitions/integer"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "items": {},+ "type": "array"+ },+ "type": "array"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "types": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ "type": "array"+ }+ },+ "required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],+ "type": "object"+ },+ "AccountsRoleAssignmentFilter": {+ "anyOf": [+ {+ "$ref": "#/definitions/integer"+ },+ {+ "const": "unassigned",+ "type": "string"+ }+ ]+ },"ActionConversionGoal": {"additionalProperties": false,"properties": {@@ -721,6 +867,9 @@{"$ref": "#/definitions/UsageMetricsQuery"},+ {+ "$ref": "#/definitions/AccountsQuery"+ },{"$ref": "#/definitions/EndpointsUsageOverviewQuery"},@@ -4647,6 +4796,118 @@"required": ["cache_key"],"type": "object"},+ "CachedAccountsQueryResponse": {+ "additionalProperties": false,+ "properties": {+ "cache_key": {+ "type": "string"+ },+ "cache_target_age": {+ "format": "date-time",+ "type": "string"+ },+ "calculation_trigger": {+ "description": "What triggered the calculation of the query, leave empty if user/immediate",+ "type": "string"+ },+ "columns": {+ "items": {},+ "type": "array"+ },+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hasMore": {+ "type": "boolean"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "is_cached": {+ "type": "boolean"+ },+ "kind": {+ "const": "AccountsQuery",+ "type": "string"+ },+ "last_refresh": {+ "format": "date-time",+ "type": "string"+ },+ "limit": {+ "$ref": "#/definitions/integer"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "next_allowed_client_refresh": {+ "format": "date-time",+ "type": "string"+ },+ "offset": {+ "$ref": "#/definitions/integer"+ },+ "query_metadata": {+ "type": "object"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "items": {},+ "type": "array"+ },+ "type": "array"+ },+ "timezone": {+ "type": "string"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "types": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ "type": "array"+ }+ },+ "required": [+ "cache_key",+ "columns",+ "hogql",+ "is_cached",+ "kind",+ "last_refresh",+ "limit",+ "next_allowed_client_refresh",+ "offset",+ "results",+ "timezone",+ "types"+ ],+ "type": "object"+ },"CachedActorsPropertyTaxonomyQueryResponse": {"additionalProperties": false,"properties": {@@ -13788,6 +14049,77 @@},"required": ["results"],"type": "object"+ },+ {+ "additionalProperties": false,+ "properties": {+ "columns": {+ "items": {},+ "type": "array"+ },+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hasMore": {+ "type": "boolean"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "kind": {+ "const": "AccountsQuery",+ "type": "string"+ },+ "limit": {+ "$ref": "#/definitions/integer"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "offset": {+ "$ref": "#/definitions/integer"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "items": {},+ "type": "array"+ },+ "type": "array"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "types": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ "type": "array"+ }+ },+ "required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],+ "type": "object"}]},@@ -13987,6 +14319,9 @@},{"$ref": "#/definitions/EndpointsUsageTableQuery"+ },+ {+ "$ref": "#/definitions/AccountsQuery"}],"description": "Source of the events"@@ -27412,6 +27747,7 @@"VectorSearchQuery","DocumentSimilarityQuery","UsageMetricsQuery",+ "AccountsQuery","EndpointsUsageOverviewQuery","EndpointsUsageTableQuery","EndpointsUsageTrendsQuery",@@ -32908,6 +33244,77 @@"required": ["results"],"type": "object"},+ {+ "additionalProperties": false,+ "properties": {+ "columns": {+ "items": {},+ "type": "array"+ },+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hasMore": {+ "type": "boolean"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "kind": {+ "const": "AccountsQuery",+ "type": "string"+ },+ "limit": {+ "$ref": "#/definitions/integer"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "offset": {+ "$ref": "#/definitions/integer"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "items": {},+ "type": "array"+ },+ "type": "array"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "types": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ "type": "array"+ }+ },+ "required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],+ "type": "object"+ },{"additionalProperties": false,"properties": {@@ -34082,6 +34489,77 @@"required": ["results"],"type": "object"},+ {+ "additionalProperties": false,+ "properties": {+ "columns": {+ "items": {},+ "type": "array"+ },+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hasMore": {+ "type": "boolean"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "kind": {+ "const": "AccountsQuery",+ "type": "string"+ },+ "limit": {+ "$ref": "#/definitions/integer"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "offset": {+ "$ref": "#/definitions/integer"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "items": {},+ "type": "array"+ },+ "type": "array"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "types": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ "type": "array"+ }+ },+ "required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],+ "type": "object"+ },{"additionalProperties": false,"properties": {@@ -34514,6 +34992,9 @@{"$ref": "#/definitions/UsageMetricsQuery"},+ {+ "$ref": "#/definitions/AccountsQuery"+ },{"$ref": "#/definitions/EndpointsUsageOverviewQuery"},diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 9160342d951b..156956208901 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -178,6 +178,7 @@ export enum NodeKind {// Customer analyticsUsageMetricsQuery = 'UsageMetricsQuery',+ AccountsQuery = 'AccountsQuery',// Endpoints usage queriesEndpointsUsageOverviewQuery = 'EndpointsUsageOverviewQuery',@@ -243,6 +244,7 @@ export type AnyDataNode =| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -348,6 +350,7 @@ export type QuerySchema =// Customer analytics| UsageMetricsQuery+ | AccountsQuery// Endpoints usage| EndpointsUsageOverviewQuery@@ -1052,6 +1055,7 @@ export interface DataTableNode| ExperimentTrendsQuery| TracesQuery| EndpointsUsageTableQuery+ | AccountsQuery)['response']>>,@@ -1090,6 +1094,7 @@ export interface DataTableNode| TracesQuery| TraceQuery| EndpointsUsageTableQuery+ | AccountsQuery/** Columns shown in the table, unless the `source` provides them. */columns?: HogQLExpression[]/** Columns that aren't shown in the table, even if in columns or returned data */@@ -2256,6 +2261,35 @@ export interface GroupsQuery extends DataNode<GroupsQueryResponse> {offset?: integer}+export type CachedAccountsQueryResponse = CachedQueryResponse<AccountsQueryResponse>++export interface AccountsQueryResponse extends AnalyticsQueryResponseBase {+ results: any[][]+ kind: NodeKind.AccountsQuery+ columns: any[]+ types: string[]+ hogql: string+ hasMore?: boolean+ limit: integer+ offset: integer+}++export type AccountsRoleAssignmentFilter = integer | 'unassigned'++export interface AccountsQuery extends DataNode<AccountsQueryResponse> {+ kind: NodeKind.AccountsQuery+ select?: HogQLExpression[]+ search?: string+ tagNames?: string[]+ csm?: AccountsRoleAssignmentFilter+ accountExecutive?: AccountsRoleAssignmentFilter+ accountOwner?: AccountsRoleAssignmentFilter+ allRolesUnassigned?: boolean+ orderBy?: string[]+ limit?: integer+ offset?: integer+}+export interface TimelineEntry {/** Session ID. None means out-of-session events */sessionId?: stringdiff --git a/frontend/src/scenes/saved-insights/SavedInsights.tsx b/frontend/src/scenes/saved-insights/SavedInsights.tsxindex 517c1484d607..f0dd340abbe1 100644--- a/frontend/src/scenes/saved-insights/SavedInsights.tsx+++ b/frontend/src/scenes/saved-insights/SavedInsights.tsx@@ -590,6 +590,11 @@ export const QUERY_TYPES_METADATA: Record<NodeKind, InsightTypeMetadata> = {icon: IconPieChart,inMenu: false,},+ [NodeKind.AccountsQuery]: {+ name: 'Accounts',+ icon: IconPieChart,+ inMenu: false,+ },[NodeKind.EndpointsUsageOverviewQuery]: {name: 'Endpoints usage overview',icon: IconPieChart,diff --git a/posthog/clickhouse/query_tagging.py b/posthog/clickhouse/query_tagging.pyindex 6cb6401d8eae..aeefabb3af63 100644--- a/posthog/clickhouse/query_tagging.py+++ b/posthog/clickhouse/query_tagging.py@@ -250,6 +250,7 @@ def kind_fallback_tags(kind: NodeKind) -> FallbackTags | None:| NodeKind.DATABASE_SCHEMA_QUERY| NodeKind.PROPERTY_VALUES_QUERY| NodeKind.USAGE_METRICS_QUERY+ | NodeKind.ACCOUNTS_QUERY# drill-downs — caller's product is what matters| NodeKind.ACTORS_QUERY| NodeKind.GROUPS_QUERYdiff --git a/posthog/hogql/database/database.py b/posthog/hogql/database/database.pyindex ccdda4328195..162e54a27018 100644--- a/posthog/hogql/database/database.py+++ b/posthog/hogql/database/database.py@@ -53,6 +53,7 @@ from posthog.hogql.database.models import (Table,TableNode,UnknownDatabaseField,+ UUIDDatabaseField,VirtualTable,)from posthog.hogql.database.postgres_table import PostgresTable@@ -487,7 +488,7 @@ class Database(BaseModel):if not isinstance(system_tables, SystemTables):return []- return ["query_log", *system_tables.resolve_all_table_names()]+ return ["query_log", *system_tables.resolve_visible_table_names()]def get_warehouse_table_names(self) -> list[str]:return self._warehouse_table_names + self._warehouse_self_managed_table_names@@ -1836,6 +1837,15 @@ def serialize_fields(schema_valid=schema_valid,))+ elif isinstance(field, UUIDDatabaseField):+ field_output.append(+ DatabaseSchemaField(+ name=field_key,+ hogql_value=hogql_value,+ type=DatabaseSerializedFieldType.STRING,+ schema_valid=schema_valid,+ )+ )elif isinstance(field, DateTimeDatabaseField):field_output.append(DatabaseSchemaField(diff --git a/posthog/hogql/database/models.py b/posthog/hogql/database/models.pyindex 02f94b34a61a..39ce0c12d2b9 100644--- a/posthog/hogql/database/models.py+++ b/posthog/hogql/database/models.py@@ -235,6 +235,9 @@ class TableNode(BaseModel):name: Literal["root"] | str = "root" # Default to root for ease of usetable: FieldOrTable | None = Nonechildren: dict[str, "TableNode"] = {}+ # When True, the table is reachable by the resolver (so other tables can reference it+ # via subqueries) but is omitted from the SQL editor schema and autocomplete lists.+ hidden: bool = Falsedef get(self) -> FieldOrTable:"""@@ -328,6 +331,31 @@ class TableNode(BaseModel):return names+ def resolve_visible_table_names(self) -> list[str]:+ """Same as `resolve_all_table_names` but skips nodes marked `hidden=True`.++ Use this for surfaces aimed at users (SQL editor schema sidebar, autocomplete,+ access-control allowlists). The resolver itself should keep using+ `resolve_all_table_names` so that hidden tables remain reachable via+ subqueries — they're just kept out of the catalog.+ """+ names: list[str] = []++ if self.table is not None and not self.hidden:+ names.append(self.name)++ for child in self.children.values():+ if child.hidden:+ continue+ child_names = child.resolve_visible_table_names()++ if self.name == "root":+ names.extend(child_names)+ else:+ names.extend([f"{self.name}.{x}" for x in child_names])++ return names+@staticmethoddef create_nested_for_chain(chain: list[str], table: Table) -> "TableNode":assert len(chain) > 0diff --git a/posthog/hogql/database/schema/account_aggregates.py b/posthog/hogql/database/schema/account_aggregates.pynew file mode 100644index 000000000000..7316b52459fd--- /dev/null+++ b/posthog/hogql/database/schema/account_aggregates.py@@ -0,0 +1,165 @@+"""Internal aggregating tables and lazy joins that power `system.accounts.tags` and+`system.accounts.notebooks`.++The two raw federated tables (`_account_tagged_items`, `_account_resource_notebooks`)+are tag/notebook junction rows from PostgreSQL. They have no `team_id` column and+should not be reachable directly from the SQL editor — they exist only so the lazy+join subqueries below can be resolved by the planner.+"""++from posthog.hogql import ast+from posthog.hogql.base import Expr+from posthog.hogql.context import HogQLContext+from posthog.hogql.database.models import (+ DANGEROUS_NoTeamIdCheckTable,+ FieldOrTable,+ IntegerDatabaseField,+ LazyJoin,+ LazyJoinToAdd,+ LazyTable,+ LazyTableToAdd,+ StringArrayDatabaseField,+ StringDatabaseField,+ UUIDDatabaseField,+)+from posthog.hogql.database.postgres_table import PostgresTable+from posthog.hogql.errors import ResolutionError+from posthog.hogql.parser import parse_expr, parse_select+++class _AccountScopedPostgresTable(PostgresTable, DANGEROUS_NoTeamIdCheckTable):+ """PostgresTable variant for FK-only junction tables that lack a `team_id` column.++ The framework's auto-injected `team_id = X` guard is bypassed because the column+ doesn't exist. Security is preserved instead via a predicate (set on the class) that+ scopes through `account_id`, relying on the framework re-applying its team_id guard+ to the inner `system.accounts` reference.++ Direct top-level SELECT remains safe because the predicate prunes rows whose FK+ doesn't resolve to a team-scoped account.+ """++ predicates: list[Expr] = [parse_expr("account_id IN (SELECT id FROM system.accounts)")]+++_account_tagged_items: _AccountScopedPostgresTable = _AccountScopedPostgresTable(+ name="_account_tagged_items",+ postgres_table_name="posthog_taggeditem",+ fields={+ "id": UUIDDatabaseField(name="id"),+ "tag_id": UUIDDatabaseField(name="tag_id"),+ "account_id": UUIDDatabaseField(name="account_id", nullable=True),+ },+)++_account_resource_notebooks: _AccountScopedPostgresTable = _AccountScopedPostgresTable(+ name="_account_resource_notebooks",+ postgres_table_name="posthog_resourcenotebook",+ fields={+ "id": UUIDDatabaseField(name="id"),+ "notebook_id": StringDatabaseField(name="notebook_id"),+ "account_id": UUIDDatabaseField(name="account_id", nullable=True),+ },+)+++def _account_tags_select() -> ast.SelectQuery | ast.SelectSetQuery:+ return parse_select(+ """+ SELECT+ ati.account_id AS account_id,+ arraySort(arrayDistinct(groupArray(t.name))) AS names+ FROM system._account_tagged_items AS ati+ INNER JOIN system.tags AS t ON t.id = ati.tag_id+ GROUP BY ati.account_id+ """+ )+++def _account_notebooks_select() -> ast.SelectQuery | ast.SelectSetQuery:+ return parse_select(+ """+ SELECT+ arn.account_id AS account_id,+ count() AS count+ FROM system._account_resource_notebooks AS arn+ GROUP BY arn.account_id+ """+ )+++class _AccountTagsTable(LazyTable):+ fields: dict[str, FieldOrTable] = {+ "account_id": UUIDDatabaseField(name="account_id"),+ "names": StringArrayDatabaseField(name="names"),+ }++ def lazy_select(+ self, table_to_add: LazyTableToAdd, context: HogQLContext, node: ast.SelectQuery+ ) -> ast.SelectQuery | ast.SelectSetQuery:+ return _account_tags_select()++ def to_printed_clickhouse(self, context: HogQLContext) -> str:+ return "account_tags"++ def to_printed_hogql(self) -> str:+ return "account_tags"+++class _AccountNotebooksTable(LazyTable):+ fields: dict[str, FieldOrTable] = {+ "account_id": UUIDDatabaseField(name="account_id"),+ "count": IntegerDatabaseField(name="count"),+ }++ def lazy_select(+ self, table_to_add: LazyTableToAdd, context: HogQLContext, node: ast.SelectQuery+ ) -> ast.SelectQuery | ast.SelectSetQuery:+ return _account_notebooks_select()++ def to_printed_clickhouse(self, context: HogQLContext) -> str:+ return "account_notebooks"++ def to_printed_hogql(self) -> str:+ return "account_notebooks"+++def _join_on_account_id(select: ast.SelectQuery | ast.SelectSetQuery, join_to_add: LazyJoinToAdd) -> ast.JoinExpr:+ return ast.JoinExpr(+ alias=join_to_add.to_table,+ table=select,+ join_type="LEFT JOIN",+ constraint=ast.JoinConstraint(+ constraint_type="ON",+ expr=ast.CompareOperation(+ op=ast.CompareOperationOp.Eq,+ left=ast.Field(chain=[join_to_add.from_table, "id"]),+ right=ast.Field(chain=[join_to_add.to_table, "account_id"]),+ ),+ ),+ )+++def _account_tags_join(join_to_add: LazyJoinToAdd, context: HogQLContext, node: ast.SelectQuery) -> ast.JoinExpr:+ if not join_to_add.fields_accessed:+ raise ResolutionError("No fields requested from `accounts.tags`")+ return _join_on_account_id(_account_tags_select(), join_to_add)+++def _account_notebooks_join(join_to_add: LazyJoinToAdd, context: HogQLContext, node: ast.SelectQuery) -> ast.JoinExpr:+ if not join_to_add.fields_accessed:+ raise ResolutionError("No fields requested from `accounts.notebooks`")+ return _join_on_account_id(_account_notebooks_select(), join_to_add)+++account_tags_lazy_join: LazyJoin = LazyJoin(+ from_field=["id"],+ join_table=_AccountTagsTable(),+ join_function=_account_tags_join,+)++account_notebooks_lazy_join: LazyJoin = LazyJoin(+ from_field=["id"],+ join_table=_AccountNotebooksTable(),+ join_function=_account_notebooks_join,+)diff --git a/posthog/hogql/database/schema/system.py b/posthog/hogql/database/schema/system.pyindex 8c770e822b4b..d7c931e72c11 100644--- a/posthog/hogql/database/schema/system.py+++ b/posthog/hogql/database/schema/system.py@@ -15,6 +15,12 @@ from posthog.hogql.database.models import (UUIDDatabaseField,)from posthog.hogql.database.postgres_table import PostgresTable+from posthog.hogql.database.schema.account_aggregates import (+ _account_resource_notebooks,+ _account_tagged_items,+ account_notebooks_lazy_join,+ account_tags_lazy_join,+)from posthog.hogql.parser import parse_expr@@ -145,9 +151,27 @@ accounts: PostgresTable = PostgresTable(name="zendesk_id",expr=parse_expr("JSONExtractString(properties, 'zendesk_id')"),),+ "csm": ExpressionField(+ name="csm",+ expr=parse_expr("JSONExtract(properties, 'csm', 'Tuple(id Nullable(Int64), email Nullable(String))')"),+ ),+ "account_executive": ExpressionField(+ name="account_executive",+ expr=parse_expr(+ "JSONExtract(properties, 'account_executive', 'Tuple(id Nullable(Int64), email Nullable(String))')"+ ),+ ),+ "account_owner": ExpressionField(+ name="account_owner",+ expr=parse_expr(+ "JSONExtract(properties, 'account_owner', 'Tuple(id Nullable(Int64), email Nullable(String))')"+ ),+ ),"created_by_id": IntegerDatabaseField(name="created_by_id", nullable=True),"created_at": DateTimeDatabaseField(name="created_at"),"updated_at": DateTimeDatabaseField(name="updated_at", nullable=True),+ "tags": account_tags_lazy_join,+ "notebooks": account_notebooks_lazy_join,},)@@ -1142,10 +1166,25 @@ sandbox_environments: PostgresTable = PostgresTable()+tags: PostgresTable = PostgresTable(+ name="tags",+ postgres_table_name="posthog_tag",+ fields={+ "id": UUIDDatabaseField(name="id"),+ "team_id": IntegerDatabaseField(name="team_id"),+ "name": StringDatabaseField(name="name"),+ },+)++class SystemTables(TableNode):name: str = "system"children: dict[str, TableNode] = {"accounts": TableNode(name="accounts", table=accounts),+ "_account_tagged_items": TableNode(name="_account_tagged_items", table=_account_tagged_items, hidden=True),+ "_account_resource_notebooks": TableNode(+ name="_account_resource_notebooks", table=_account_resource_notebooks, hidden=True+ ),"activity_logs": TableNode(name="activity_logs", table=activity_logs),"actions": TableNode(name="actions", table=actions),"alerts": TableNode(name="alerts", table=alerts),@@ -1206,6 +1245,7 @@ class SystemTables(TableNode):"support_tickets": TableNode(name="support_tickets", table=support_tickets),"surveys": TableNode(name="surveys", table=surveys),"task_runs": TableNode(name="task_runs", table=task_runs),+ "tags": TableNode(name="tags", table=tags),"tasks": TableNode(name="tasks", table=tasks),"teams": TableNode(name="teams", table=teams),"trace_review_scores": TableNode(name="trace_review_scores", table=trace_review_scores),diff --git a/posthog/hogql/database/schema/test/test_system_tables.py b/posthog/hogql/database/schema/test/test_system_tables.pyindex e0483f97baff..a678349d4186 100644--- a/posthog/hogql/database/schema/test/test_system_tables.py+++ b/posthog/hogql/database/schema/test/test_system_tables.py@@ -18,6 +18,7 @@ from posthog.models import (GroupTypeMapping,GroupUsageMetric,Organization,+ Tag,Team,)from posthog.models.activity_logging.activity_log import ActivityLog@@ -42,7 +43,7 @@ from products.error_tracking.backend.models import ErrorTrackingIssue, ErrorTracfrom products.experiments.backend.models.experiment import Experimentfrom products.feature_flags.backend.models.feature_flag import FeatureFlagfrom products.logs.backend.models import LogsAlertConfiguration, LogsView-from products.notebooks.backend.models import Notebook+from products.notebooks.backend.models import Notebook, ResourceNotebookfrom products.product_analytics.backend.models.insight import Insightfrom products.product_analytics.backend.models.insight_variable import InsightVariablefrom products.surveys.backend.models import Survey@@ -58,6 +59,9 @@ ALL_SYSTEM_TABLE_NAMES = sorted(SystemTables().children.keys())TEAM_ID_FILTER_PATTERNS = {"ingestion_warnings": "ingestion_warnings.team_id", # ClickHouse-native table, no system__ prefix"teams": "system__teams.id", # team_id is aliased to id column+ # Junction tables without team_id; isolation is enforced via an account_id IN system.accounts predicate+ "_account_resource_notebooks": "system__accounts.team_id",+ "_account_tagged_items": "system__accounts.team_id",}@@ -86,6 +90,10 @@ class TestSystemTablesTeamScoping(BaseTest):# ingestion_warnings is a ClickHouse-native table (not backed by PostgreSQL),# so it can't be tested with Django model factories."ingestion_warnings",+ # Hidden junction tables that exist only to back the system.accounts lazy joins;+ # isolation is covered by TestSystemAccountsLazyJoins.+ "_account_resource_notebooks",+ "_account_tagged_items",}untested = all_tables - tested_tables - excluded_tables@@ -509,6 +517,10 @@ def _create_sandbox_environment(team: Team, label: str):return SandboxEnvironment.objects.create(team=team, name=f"env_{label}", private=False)+def _create_tag(team: Team, label: str) -> Tag:+ return Tag.objects.create(team=team, name=f"tag_{label}")++def _create_team(team: Team, label: str) -> Team:return team@@ -572,6 +584,7 @@ SYSTEM_TABLE_FACTORIES = [("source_schemas", _create_source_schema),("support_tickets", _create_support_ticket),("surveys", _create_survey),+ ("tags", _create_tag),("task_runs", _create_task_run),("tasks", _create_task),("teams", _create_team),@@ -695,3 +708,57 @@ class TestSystemTablesTaskInternalExclusionIsolation(NonAtomicBaseTest):assert str(regular_task.pk) in idsassert str(internal_task.pk) not in ids+++class TestSystemAccountsLazyJoins(NonAtomicBaseTest):+ """Verify the `accounts.tags.names` and `accounts.notebooks.count` lazy joins."""++ CLASS_DATA_LEVEL_SETUP = False++ def setUp(self):+ super().setUp()+ other_org = Organization.objects.create(name="other_org")+ other_project = Project.objects.create(id=Team.objects.increment_id_sequence(), organization=other_org)+ self.other_team = Team.objects.create(id=other_project.id, project=other_project, organization=other_org)++ def test_tags_lazy_join_returns_tag_names_array(self):+ account = Account.objects.unscoped().create(team=self.team, name="A")+ billing = Tag.objects.create(name="billing", team=self.team)+ urgent = Tag.objects.create(name="urgent", team=self.team)+ account.tagged_items.create(tag=billing)+ account.tagged_items.create(tag=urgent)+ Account.objects.unscoped().create(team=self.team, name="B") # untagged++ response = execute_hogql_query(+ "SELECT id, accounts.tags.names FROM system.accounts AS accounts ORDER BY name",+ team=self.team,+ )+ rows_by_id = {str(row[0]): row[1] for row in response.results}++ assert sorted(rows_by_id[str(account.id)]) == ["billing", "urgent"]++ def test_tags_lazy_join_isolated_per_team(self):+ other_account = Account.objects.unscoped().create(team=self.other_team, name="Theirs")+ other_tag = Tag.objects.create(name="billing", team=self.other_team)+ other_account.tagged_items.create(tag=other_tag)++ response = execute_hogql_query(+ "SELECT id, accounts.tags.names FROM system.accounts AS accounts",+ team=self.team,+ )+ assert response.results == []++ def test_notebooks_lazy_join_returns_count(self):+ account = Account.objects.unscoped().create(team=self.team, name="A")+ for label in ("n1", "n2", "n3"):+ notebook = Notebook.objects.create(team=self.team, title=label)+ ResourceNotebook.objects.create(notebook=notebook, account=account)+ Account.objects.unscoped().create(team=self.team, name="B") # no notebooks++ response = execute_hogql_query(+ "SELECT id, accounts.notebooks.count FROM system.accounts AS accounts ORDER BY name",+ team=self.team,+ )+ rows_by_id = {str(row[0]): row[1] for row in response.results}++ assert rows_by_id[str(account.id)] == 3diff --git a/posthog/hogql/database/test/__snapshots__/test_database.ambr b/posthog/hogql/database/test/__snapshots__/test_database.ambrindex 12be53758e69..ddbb731e082b 100644--- a/posthog/hogql/database/test/__snapshots__/test_database.ambr+++ b/posthog/hogql/database/test/__snapshots__/test_database.ambr@@ -2349,6 +2349,16 @@},"system.accounts": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"external_id": {"chain": null,"fields": null,@@ -2429,6 +2439,36 @@"table": null,"type": "string"},+ "csm": {+ "chain": null,+ "fields": null,+ "hogql_value": "csm",+ "id": null,+ "name": "csm",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "account_executive": {+ "chain": null,+ "fields": null,+ "hogql_value": "account_executive",+ "id": null,+ "name": "account_executive",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "account_owner": {+ "chain": null,+ "fields": null,+ "hogql_value": "account_owner",+ "id": null,+ "name": "account_owner",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"created_by_id": {"chain": null,"fields": null,@@ -6297,6 +6337,26 @@},"system.review_queue_items": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "queue_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "queue_id",+ "id": null,+ "name": "queue_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"trace_id": {"chain": null,"fields": null,@@ -6365,6 +6425,16 @@},"system.review_queues": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"name": {"chain": null,"fields": null,@@ -6433,6 +6503,16 @@},"system.score_definitions": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"name": {"chain": null,"fields": null,@@ -6473,6 +6553,16 @@"table": null,"type": "boolean"},+ "current_version_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "current_version_id",+ "id": null,+ "name": "current_version_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"created_by_id": {"chain": null,"fields": null,@@ -7535,6 +7625,34 @@"row_count": null,"type": "system"},+ "system.tags": {+ "fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "name": {+ "chain": null,+ "fields": null,+ "hogql_value": "name",+ "id": null,+ "name": "name",+ "schema_valid": true,+ "table": null,+ "type": "string"+ }+ },+ "id": "system.tags",+ "name": "system.tags",+ "row_count": null,+ "type": "system"+ },"system.tasks": {"fields": {"id": {@@ -7763,6 +7881,46 @@},"system.trace_review_scores": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "review_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "review_id",+ "id": null,+ "name": "review_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "definition_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "definition_id",+ "id": null,+ "name": "definition_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "definition_version": {+ "chain": null,+ "fields": null,+ "hogql_value": "definition_version",+ "id": null,+ "name": "definition_version",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"definition_version_number": {"chain": null,"fields": null,@@ -7851,6 +8009,16 @@},"system.trace_reviews": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"trace_id": {"chain": null,"fields": null,@@ -9858,6 +10026,16 @@},"system.accounts": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"external_id": {"chain": null,"fields": null,@@ -9938,6 +10116,36 @@"table": null,"type": "string"},+ "csm": {+ "chain": null,+ "fields": null,+ "hogql_value": "csm",+ "id": null,+ "name": "csm",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "account_executive": {+ "chain": null,+ "fields": null,+ "hogql_value": "account_executive",+ "id": null,+ "name": "account_executive",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "account_owner": {+ "chain": null,+ "fields": null,+ "hogql_value": "account_owner",+ "id": null,+ "name": "account_owner",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"created_by_id": {"chain": null,"fields": null,@@ -13806,6 +14014,26 @@},"system.review_queue_items": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "queue_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "queue_id",+ "id": null,+ "name": "queue_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"trace_id": {"chain": null,"fields": null,@@ -13874,6 +14102,16 @@},"system.review_queues": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"name": {"chain": null,"fields": null,@@ -13942,6 +14180,16 @@},"system.score_definitions": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"name": {"chain": null,"fields": null,@@ -13982,6 +14230,16 @@"table": null,"type": "boolean"},+ "current_version_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "current_version_id",+ "id": null,+ "name": "current_version_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"created_by_id": {"chain": null,"fields": null,@@ -15044,6 +15302,34 @@"row_count": null,"type": "system"},+ "system.tags": {+ "fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "name": {+ "chain": null,+ "fields": null,+ "hogql_value": "name",+ "id": null,+ "name": "name",+ "schema_valid": true,+ "table": null,+ "type": "string"+ }+ },+ "id": "system.tags",+ "name": "system.tags",+ "row_count": null,+ "type": "system"+ },"system.tasks": {"fields": {"id": {@@ -15272,6 +15558,46 @@},"system.trace_review_scores": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "review_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "review_id",+ "id": null,+ "name": "review_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "definition_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "definition_id",+ "id": null,+ "name": "definition_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "definition_version": {+ "chain": null,+ "fields": null,+ "hogql_value": "definition_version",+ "id": null,+ "name": "definition_version",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"definition_version_number": {"chain": null,"fields": null,@@ -15360,6 +15686,16 @@},"system.trace_reviews": {"fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },"trace_id": {"chain": null,"fields": null,diff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.pyindex 2ada15261ca1..6c38f191cf55 100644--- a/posthog/hogql_queries/query_runner.py+++ b/posthog/hogql_queries/query_runner.py@@ -12,6 +12,7 @@ from prometheus_client import Counter, Histogramfrom pydantic import BaseModel, ConfigDictfrom posthog.schema import (+ AccountsQuery,ActorsPropertyTaxonomyQuery,ActorsQuery,BreakdownType,@@ -301,6 +302,7 @@ RunnableQueryNode = Union[MarketingAnalyticsAggregatedQuery,ActorsPropertyTaxonomyQuery,UsageMetricsQuery,+ AccountsQuery,EndpointsUsageOverviewQuery,EndpointsUsageTableQuery,EndpointsUsageTrendsQuery,@@ -1021,6 +1023,18 @@ def get_query_runner(user=user,)+ if kind == "AccountsQuery":+ from products.customer_analytics.backend.hogql_queries.accounts_query_runner import AccountsQueryRunner++ return AccountsQueryRunner(+ query=query,+ team=team,+ timings=timings,+ modifiers=modifiers,+ limit_context=limit_context,+ user=user,+ )+if kind == "EndpointsUsageOverviewQuery":from .endpoints.endpoints_usage_overview import EndpointsUsageOverviewQueryRunnerdiff --git a/posthog/schema.py b/posthog/schema.pyindex e3d13cbc5fc7..fffea5bef79e 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -3675,6 +3675,7 @@ class NodeKind(StrEnum):VECTOR_SEARCH_QUERY = "VectorSearchQuery"DOCUMENT_SIMILARITY_QUERY = "DocumentSimilarityQuery"USAGE_METRICS_QUERY = "UsageMetricsQuery"+ ACCOUNTS_QUERY = "AccountsQuery"ENDPOINTS_USAGE_OVERVIEW_QUERY = "EndpointsUsageOverviewQuery"ENDPOINTS_USAGE_TABLE_QUERY = "EndpointsUsageTableQuery"ENDPOINTS_USAGE_TRENDS_QUERY = "EndpointsUsageTrendsQuery"@@ -4121,7 +4122,7 @@ class QueryResponseAlternative7(BaseModel):stdout: str | None = None-class QueryResponseAlternative81(BaseModel):+class QueryResponseAlternative82(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -7938,7 +7939,7 @@ class QueryResponseAlternative29(BaseModel):status: ExternalQueryStatus-class QueryResponseAlternative87(BaseModel):+class QueryResponseAlternative88(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -9859,6 +9860,49 @@ class ZScoreDetectorConfig(BaseModel):)+class AccountsQueryResponse(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ columns: list+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hasMore: bool | None = None+ hogql: str = Field(..., description="Generated HogQL query.")+ kind: Literal["AccountsQuery"] = "AccountsQuery"+ limit: int+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ offset: int+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[list]+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ types: list[str]+ warnings: list[DataWarehouseSyncWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose latest"+ " sync failed, is paused, hit a billing limit, or is otherwise stale."+ " Results may not reflect current source data. Accumulated across every"+ " HogQL execution that contributes to this response — so insights backed by"+ " warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw"+ " HogQL queries."+ ),+ )++class ActorsPropertyTaxonomyQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",@@ -11208,6 +11252,60 @@ class CacheMissResponse(BaseModel):query_status: QueryStatus | None = None+class CachedAccountsQueryResponse(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ cache_key: str+ cache_target_age: AwareDatetime | None = None+ calculation_trigger: str | None = Field(+ default=None,+ description=("What triggered the calculation of the query, leave empty if user/immediate"),+ )+ columns: list+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hasMore: bool | None = None+ hogql: str = Field(..., description="Generated HogQL query.")+ is_cached: bool+ kind: Literal["AccountsQuery"] = "AccountsQuery"+ last_refresh: AwareDatetime+ limit: int+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ next_allowed_client_refresh: AwareDatetime+ offset: int+ query_metadata: dict[str, Any] | None = None+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[list]+ timezone: str+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ types: list[str]+ warnings: list[DataWarehouseSyncWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose latest"+ " sync failed, is paused, hit a billing limit, or is otherwise stale."+ " Results may not reflect current source data. Accumulated across every"+ " HogQL execution that contributes to this response — so insights backed by"+ " warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw"+ " HogQL queries."+ ),+ )++class CachedActorsPropertyTaxonomyQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",@@ -15164,6 +15262,49 @@ class Response26(BaseModel):)+class Response27(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ columns: list+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hasMore: bool | None = None+ hogql: str = Field(..., description="Generated HogQL query.")+ kind: Literal["AccountsQuery"] = "AccountsQuery"+ limit: int+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ offset: int+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[list]+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ types: list[str]+ warnings: list[DataWarehouseSyncWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose latest"+ " sync failed, is paused, hit a billing limit, or is otherwise stale."+ " Results may not reflect current source data. Accumulated across every"+ " HogQL execution that contributes to this response — so insights backed by"+ " warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw"+ " HogQL queries."+ ),+ )++class DataWarehouseNode(BaseModel):model_config = ConfigDict(extra="forbid",@@ -19483,6 +19624,49 @@ class QueryResponseAlternative65(BaseModel):class QueryResponseAlternative66(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ columns: list+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hasMore: bool | None = None+ hogql: str = Field(..., description="Generated HogQL query.")+ kind: Literal["AccountsQuery"] = "AccountsQuery"+ limit: int+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ offset: int+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[list]+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ types: list[str]+ warnings: list[DataWarehouseSyncWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose latest"+ " sync failed, is paused, hit a billing limit, or is otherwise stale."+ " Results may not reflect current source data. Accumulated across every"+ " HogQL execution that contributes to this response — so insights backed by"+ " warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw"+ " HogQL queries."+ ),+ )+++class QueryResponseAlternative67(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19521,7 +19705,7 @@ class QueryResponseAlternative66(BaseModel):)-class QueryResponseAlternative67(BaseModel):+class QueryResponseAlternative68(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19558,7 +19742,7 @@ class QueryResponseAlternative67(BaseModel):)-class QueryResponseAlternative68(BaseModel):+class QueryResponseAlternative69(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19595,7 +19779,7 @@ class QueryResponseAlternative68(BaseModel):)-class QueryResponseAlternative69(BaseModel):+class QueryResponseAlternative70(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19632,7 +19816,7 @@ class QueryResponseAlternative69(BaseModel):)-class QueryResponseAlternative70(BaseModel):+class QueryResponseAlternative71(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19669,7 +19853,7 @@ class QueryResponseAlternative70(BaseModel):)-class QueryResponseAlternative72(BaseModel):+class QueryResponseAlternative73(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19711,7 +19895,7 @@ class QueryResponseAlternative72(BaseModel):)-class QueryResponseAlternative74(BaseModel):+class QueryResponseAlternative75(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19753,7 +19937,7 @@ class QueryResponseAlternative74(BaseModel):)-class QueryResponseAlternative75(BaseModel):+class QueryResponseAlternative76(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19795,7 +19979,7 @@ class QueryResponseAlternative75(BaseModel):)-class QueryResponseAlternative76(BaseModel):+class QueryResponseAlternative77(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19833,7 +20017,7 @@ class QueryResponseAlternative76(BaseModel):)-class QueryResponseAlternative77(BaseModel):+class QueryResponseAlternative78(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19870,7 +20054,7 @@ class QueryResponseAlternative77(BaseModel):)-class QueryResponseAlternative78(BaseModel):+class QueryResponseAlternative79(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19911,7 +20095,7 @@ class QueryResponseAlternative78(BaseModel):)-class QueryResponseAlternative79(BaseModel):+class QueryResponseAlternative80(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19952,7 +20136,7 @@ class QueryResponseAlternative79(BaseModel):)-class QueryResponseAlternative80(BaseModel):+class QueryResponseAlternative81(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -19993,7 +20177,7 @@ class QueryResponseAlternative80(BaseModel):)-class QueryResponseAlternative82(BaseModel):+class QueryResponseAlternative83(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20033,7 +20217,7 @@ class QueryResponseAlternative82(BaseModel):)-class QueryResponseAlternative83(BaseModel):+class QueryResponseAlternative84(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20073,7 +20257,7 @@ class QueryResponseAlternative83(BaseModel):)-class QueryResponseAlternative84(BaseModel):+class QueryResponseAlternative85(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20110,7 +20294,7 @@ class QueryResponseAlternative84(BaseModel):)-class QueryResponseAlternative85(BaseModel):+class QueryResponseAlternative86(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20151,7 +20335,7 @@ class QueryResponseAlternative85(BaseModel):)-class QueryResponseAlternative88(BaseModel):+class QueryResponseAlternative89(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20188,7 +20372,7 @@ class QueryResponseAlternative88(BaseModel):)-class QueryResponseAlternative89(BaseModel):+class QueryResponseAlternative90(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20225,7 +20409,50 @@ class QueryResponseAlternative89(BaseModel):)-class QueryResponseAlternative90(BaseModel):+class QueryResponseAlternative91(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ columns: list+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hasMore: bool | None = None+ hogql: str = Field(..., description="Generated HogQL query.")+ kind: Literal["AccountsQuery"] = "AccountsQuery"+ limit: int+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ offset: int+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[list]+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ types: list[str]+ warnings: list[DataWarehouseSyncWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose latest"+ " sync failed, is paused, hit a billing limit, or is otherwise stale."+ " Results may not reflect current source data. Accumulated across every"+ " HogQL execution that contributes to this response — so insights backed by"+ " warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw"+ " HogQL queries."+ ),+ )+++class QueryResponseAlternative92(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20262,7 +20489,7 @@ class QueryResponseAlternative90(BaseModel):)-class QueryResponseAlternative91(BaseModel):+class QueryResponseAlternative93(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20304,7 +20531,7 @@ class QueryResponseAlternative91(BaseModel):)-class QueryResponseAlternative92(BaseModel):+class QueryResponseAlternative94(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -20341,7 +20568,7 @@ class QueryResponseAlternative92(BaseModel):)-class QueryResponseAlternative93(BaseModel):+class QueryResponseAlternative95(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21479,6 +21706,27 @@ class WebVitalsQueryResponse(BaseModel):)+class AccountsQuery(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ accountExecutive: str | int | None = None+ accountOwner: str | int | None = None+ allRolesUnassigned: bool | None = None+ csm: str | int | None = None+ kind: Literal["AccountsQuery"] = "AccountsQuery"+ limit: int | None = None+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ offset: int | None = None+ orderBy: list[str] | None = None+ response: AccountsQueryResponse | None = None+ search: str | None = None+ select: list[str] | None = None+ tagNames: list[str] | None = None+ tags: QueryLogTags | None = None+ version: float | None = Field(default=None, description="version of the node, used for schema migrations")++class ActionsNode(BaseModel):model_config = ConfigDict(extra="forbid",@@ -24650,7 +24898,7 @@ class QueryResponseAlternative63(BaseModel):)-class QueryResponseAlternative73(BaseModel):+class QueryResponseAlternative74(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -25094,7 +25342,7 @@ class QueryResponseAlternative(| QueryResponseAlternative68| QueryResponseAlternative69| QueryResponseAlternative70- | QueryResponseAlternative72+ | QueryResponseAlternative71| QueryResponseAlternative73| QueryResponseAlternative74| QueryResponseAlternative75@@ -25108,13 +25356,15 @@ class QueryResponseAlternative(| QueryResponseAlternative83| QueryResponseAlternative84| QueryResponseAlternative85- | QueryResponseAlternative87+ | QueryResponseAlternative86| QueryResponseAlternative88| QueryResponseAlternative89| QueryResponseAlternative90| QueryResponseAlternative91| QueryResponseAlternative92| QueryResponseAlternative93+ | QueryResponseAlternative94+ | QueryResponseAlternative95]):root: (@@ -25186,7 +25436,7 @@ class QueryResponseAlternative(| QueryResponseAlternative68| QueryResponseAlternative69| QueryResponseAlternative70- | QueryResponseAlternative72+ | QueryResponseAlternative71| QueryResponseAlternative73| QueryResponseAlternative74| QueryResponseAlternative75@@ -25200,13 +25450,15 @@ class QueryResponseAlternative(| QueryResponseAlternative83| QueryResponseAlternative84| QueryResponseAlternative85- | QueryResponseAlternative87+ | QueryResponseAlternative86| QueryResponseAlternative88| QueryResponseAlternative89| QueryResponseAlternative90| QueryResponseAlternative91| QueryResponseAlternative92| QueryResponseAlternative93+ | QueryResponseAlternative94+ | QueryResponseAlternative95)@@ -26010,6 +26262,7 @@ class DataTableNode(BaseModel):| Response24| Response25| Response26+ | Response27| None) = NoneshowAbsoluteTime: bool | None = Field(@@ -26103,6 +26356,7 @@ class DataTableNode(BaseModel):| TracesQuery| TraceQuery| EndpointsUsageTableQuery+ | AccountsQuery) = Field(..., description="Source of the events")tags: QueryLogTags | None = Noneversion: float | None = Field(default=None, description="version of the node, used for schema migrations")@@ -26194,6 +26448,7 @@ class HogQLAutocomplete(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26278,6 +26533,7 @@ class HogQLMetadata(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26400,6 +26656,7 @@ class MaxInsightContext(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26519,6 +26776,7 @@ class QueryRequest(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26630,6 +26888,7 @@ class QuerySchemaRoot(| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26711,6 +26970,7 @@ class QuerySchemaRoot(| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26797,6 +27057,7 @@ class QueryUpgradeRequest(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -26883,6 +27144,7 @@ class QueryUpgradeResponse(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery@@ -27120,6 +27382,7 @@ class VisualizationArtifactContent(BaseModel):| TraceNeighborsQuery| VectorSearchQuery| UsageMetricsQuery+ | AccountsQuery| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuerydiff --git a/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py b/products/customer_analytics/backend/hogql_queries/accounts_query_runner.pynew file mode 100644index 000000000000..d11bd8856bb2--- /dev/null+++ b/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py@@ -0,0 +1,156 @@+from posthog.schema import AccountsQuery, AccountsQueryResponse, CachedAccountsQueryResponse++from posthog.hogql import ast+from posthog.hogql.parser import parse_expr, parse_order_expr, parse_select++from posthog.hogql_queries.insights.paginators import HogQLHasMorePaginator+from posthog.hogql_queries.query_runner import AnalyticsQueryRunner+from posthog.models import User+from posthog.rbac.user_access_control import UserAccessControl++DEFAULT_COLUMNS = ("id", "name", "external_id", "created_at")++DEFAULT_ORDER_BY = "created_at DESC"+++def _normalize_order_clause(raw: str) -> str:+ """Allow Django-style `-col` shorthand alongside native HogQL `col DESC`."""+ stripped = raw.strip()+ if stripped.startswith("-"):+ return f"{stripped[1:].strip()} DESC"+ return stripped+++ROLE_FIELDS = {+ "csm": "csm",+ "accountExecutive": "account_executive",+ "accountOwner": "account_owner",+}+++class AccountsQueryRunner(AnalyticsQueryRunner[AccountsQueryResponse]):+ query: AccountsQuery+ cached_response: CachedAccountsQueryResponse++ def __init__(self, *args, **kwargs):+ super().__init__(*args, **kwargs)++ if self.query.select:+ seen: set[str] = set()+ self.columns: list[str] = []+ self._select_exprs: list[ast.Expr] = []+ for col in self.query.select:+ expr = parse_expr(col)+ column_name = expr.alias if isinstance(expr, ast.Alias) else col+ if column_name in seen:+ continue+ seen.add(column_name)+ self.columns.append(column_name)+ self._select_exprs.append(expr)+ else:+ self.columns = list(DEFAULT_COLUMNS)+ self._select_exprs = [parse_expr(col) for col in self.columns]++ self.paginator = HogQLHasMorePaginator.from_limit_context(+ limit_context=self.limit_context,+ limit=self.query.limit,+ offset=self.query.offset,+ )++ def validate_query_runner_access(self, user: User) -> bool:+ return UserAccessControl(user=user, team=self.team).assert_access_level_for_resource(+ "customer_analytics", "viewer"+ )++ def to_query(self) -> ast.SelectQuery:+ where_exprs: list[ast.Expr] = []++ if self.query.search and self.query.search.strip():+ pattern = f"%{self.query.search.strip()}%"+ where_exprs.append(+ parse_expr(+ "name ILIKE {pattern} OR external_id ILIKE {pattern}",+ {"pattern": ast.Constant(value=pattern)},+ )+ )++ if self.query.tagNames:+ where_exprs.append(self._tag_filter_expr(self.query.tagNames))++ for query_field, json_key in ROLE_FIELDS.items():+ role_value = getattr(self.query, query_field, None)+ role_expr = self._role_filter_expr(json_key, role_value)+ if role_expr is not None:+ where_exprs.append(role_expr)++ if self.query.allRolesUnassigned:+ for json_key in ROLE_FIELDS.values():+ where_exprs.append(self._role_id_isnull(json_key))++ order_clauses = self.query.orderBy or [DEFAULT_ORDER_BY]++ return ast.SelectQuery(+ select=self._select_exprs,+ select_from=ast.JoinExpr(+ table=ast.Field(chain=["system", "accounts"]),+ alias="accounts",+ ),+ where=ast.And(exprs=where_exprs) if where_exprs else None,+ order_by=[parse_order_expr(_normalize_order_clause(c), timings=self.timings) for c in order_clauses],+ )++ def _tag_filter_expr(self, tag_names: list[str]) -> ast.Expr:+ subquery = parse_select(+ """+ SELECT ti.account_id+ FROM system._account_tagged_items AS ti+ INNER JOIN system.tags AS t ON t.id = ti.tag_id+ WHERE t.name IN {tag_names}+ """,+ {"tag_names": ast.Constant(value=list(tag_names))},+ )+ return parse_expr("id IN {subquery}", {"subquery": subquery})++ def _role_filter_expr(self, json_key: str, value: object) -> ast.Expr | None:+ if value is None:+ return None+ if value == "unassigned":+ return self._role_id_isnull(json_key)+ try:+ user_id = int(value) # type: ignore[call-overload]+ except (TypeError, ValueError):+ return None+ return parse_expr(+ "JSONExtract(properties, {role_key}, 'id', 'Nullable(Int64)') = {user_id}",+ {+ "role_key": ast.Constant(value=json_key),+ "user_id": ast.Constant(value=user_id),+ },+ )++ def _role_id_isnull(self, json_key: str) -> ast.Expr:+ return parse_expr(+ "isNull(JSONExtract(properties, {role_key}, 'id', 'Nullable(Int64)'))",+ {"role_key": ast.Constant(value=json_key)},+ )++ def _calculate(self) -> AccountsQueryResponse:+ response = self.paginator.execute_hogql_query(+ query_type="AccountsQuery",+ query=self.to_query(),+ team=self.team,+ user=self.user,+ timings=self.timings,+ modifiers=self.modifiers,+ )++ return AccountsQueryResponse(+ kind="AccountsQuery",+ columns=list(self.columns),+ results=self.paginator.results,+ types=[t for _, t in response.types] if response.types else [],+ hogql=response.hogql or "",+ timings=response.timings,+ modifiers=self.modifiers,+ **self.paginator.response_params(),+ )diff --git a/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.py b/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.pynew file mode 100644index 000000000000..9da4664156b2--- /dev/null+++ b/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.py@@ -0,0 +1,269 @@+from posthog.test.base import ClickhouseTestMixin, NonAtomicBaseTest++from django.test import override_settings+from django.utils import timezone++from parameterized import parameterized++from posthog.schema import AccountsQuery, AccountsQueryResponse++from posthog.api.tagged_item import set_tags_on_object+from posthog.constants import AvailableFeature+from posthog.models import Tag+from posthog.models.team import Team+from posthog.rbac.user_access_control import UserAccessControlError++from products.customer_analytics.backend.hogql_queries.accounts_query_runner import AccountsQueryRunner+from products.customer_analytics.backend.test.factories import create_account++try:+ from ee.models.rbac.access_control import AccessControl+except ImportError:+ pass+++@override_settings(IN_UNIT_TESTING=True)+class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):+ def _run_query(self, **query_kwargs) -> tuple[AccountsQueryRunner, AccountsQueryResponse]:+ runner = AccountsQueryRunner(query=AccountsQuery(**query_kwargs), team=self.team)+ return runner, runner.calculate()++ def _ids(self, **query_kwargs) -> list[str]:+ runner, response = self._run_query(**query_kwargs)+ id_index = runner.columns.index("id")+ return [str(row[id_index]) for row in response.results]++ def test_team_isolation(self):+ mine_1 = create_account(team_id=self.team.id, name="Mine 1")+ mine_2 = create_account(team_id=self.team.id, name="Mine 2")++ other_team = Team.objects.create(organization=self.organization)+ create_account(team_id=other_team.id, name="Theirs")++ self.assertEqual(set(self._ids()), {str(mine_1.id), str(mine_2.id)})++ def test_default_ordering_is_created_at_desc(self):+ with timezone.override("UTC"):+ older = create_account(team_id=self.team.id, name="Older")+ newer = create_account(team_id=self.team.id, name="Newer")+ self.assertEqual(self._ids(), [str(newer.id), str(older.id)])++ @parameterized.expand(+ [+ ("name_exact", "Acme Corp", ["Acme Corp"]),+ ("name_partial_case_insensitive", "acme", ["Acme Corp"]),+ ("external_id_partial", "glx-9", ["Globex"]),+ ("matches_name_or_external_id", "1", ["Acme Corp"]),+ ("no_match", "zzzz", []),+ ]+ )+ def test_search(self, _name, search, expected_names):+ create_account(team_id=self.team.id, name="Acme Corp", external_id="acme-1")+ create_account(team_id=self.team.id, name="Globex", external_id="glx-99")++ runner, response = self._run_query(search=search)+ name_idx = runner.columns.index("name")+ self.assertEqual(sorted(r[name_idx] for r in response.results), sorted(expected_names))++ def test_blank_search_returns_all(self):+ create_account(team_id=self.team.id, name="A")+ create_account(team_id=self.team.id, name="B")+ self.assertEqual(len(self._ids(search="")), 2)+ self.assertEqual(len(self._ids(search=" ")), 2)++ def test_search_respects_team_isolation(self):+ other_team = Team.objects.create(organization=self.organization)+ create_account(team_id=other_team.id, name="Acme")+ create_account(team_id=self.team.id, name="Acme")+ self.assertEqual(len(self._ids(search="acme")), 1)++ def test_tags_filter_or_semantics(self):+ billing_tag = Tag.objects.create(name="billing", team=self.team)+ urgent_tag = Tag.objects.create(name="urgent", team=self.team)+ churn_tag = Tag.objects.create(name="churn", team=self.team)++ billing = create_account(team_id=self.team.id, name="Billing Co")+ billing.tagged_items.create(tag=billing_tag)+ urgent = create_account(team_id=self.team.id, name="Urgent Co")+ urgent.tagged_items.create(tag=urgent_tag)+ churn = create_account(team_id=self.team.id, name="Churn Co")+ churn.tagged_items.create(tag=churn_tag)+ create_account(team_id=self.team.id, name="Untagged Co")++ self.assertEqual(set(self._ids(tagNames=["billing", "urgent"])), {str(billing.id), str(urgent.id)})++ def test_tags_filter_deduplicates_multi_match(self):+ billing_tag = Tag.objects.create(name="billing", team=self.team)+ urgent_tag = Tag.objects.create(name="urgent", team=self.team)+ churn_tag = Tag.objects.create(name="churn", team=self.team)++ both_tags = create_account(team_id=self.team.id, name="Both Tagged")+ both_tags.tagged_items.create(tag=billing_tag)+ both_tags.tagged_items.create(tag=urgent_tag)++ billing_only = create_account(team_id=self.team.id, name="Billing Only")+ billing_only.tagged_items.create(tag=billing_tag)++ other_tag_account = create_account(team_id=self.team.id, name="Churn Only")+ other_tag_account.tagged_items.create(tag=churn_tag)++ create_account(team_id=self.team.id, name="Untagged")++ ids = self._ids(tagNames=["billing", "urgent"])+ self.assertEqual(sorted(ids), sorted([str(both_tags.id), str(billing_only.id)]))+ # both_tags must appear exactly once even though it matches via two tagged_items rows.+ self.assertEqual(ids.count(str(both_tags.id)), 1)++ def test_tags_empty_list_returns_all(self):+ a = create_account(team_id=self.team.id, name="A")+ b = create_account(team_id=self.team.id, name="B")+ tagged = create_account(team_id=self.team.id, name="Tagged")+ tagged.tagged_items.create(tag=Tag.objects.create(name="some_tag", team=self.team))++ self.assertEqual(set(self._ids(tagNames=[])), {str(a.id), str(b.id), str(tagged.id)})++ def test_tags_filter_respects_team_isolation_via_tag_table(self):+ other_team = Team.objects.create(organization=self.organization)+ other_tag = Tag.objects.create(name="billing", team=other_team)+ other_account = create_account(team_id=other_team.id, name="Other")+ other_account.tagged_items.create(tag=other_tag)++ local_tag = Tag.objects.create(name="billing", team=self.team)+ local_account = create_account(team_id=self.team.id, name="Mine")+ local_account.tagged_items.create(tag=local_tag)++ self.assertEqual(self._ids(tagNames=["billing"]), [str(local_account.id)])++ def test_csm_filter_by_id(self):+ match = create_account(team_id=self.team.id, name="Has CSM", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ create_account(team_id=self.team.id, name="Other CSM", _properties={"csm": {"id": 9, "email": "[email protected]"}})+ self.assertEqual(self._ids(csm=7), [str(match.id)])++ @parameterized.expand(+ [+ ("absent_keys", {"_properties": {}}),+ ("null_valued_keys", {"properties": {}}),+ ]+ )+ def test_csm_unassigned_matches_missing_and_null(self, _name, unassigned_kwargs):+ create_account(team_id=self.team.id, name="Assigned", properties={"csm": {"id": 7, "email": "[email protected]"}})+ unassigned = create_account(team_id=self.team.id, name="Unassigned", **unassigned_kwargs)+ self.assertEqual(self._ids(csm="unassigned"), [str(unassigned.id)])++ def test_account_executive_filter_by_id(self):+ match = create_account(+ team_id=self.team.id, name="A", _properties={"account_executive": {"id": 7, "email": "[email protected]"}}+ )+ create_account(team_id=self.team.id, name="B")+ self.assertEqual(self._ids(accountExecutive=7), [str(match.id)])++ def test_account_owner_filter_by_id(self):+ match = create_account(+ team_id=self.team.id, name="A", _properties={"account_owner": {"id": 7, "email": "[email protected]"}}+ )+ create_account(team_id=self.team.id, name="B")+ self.assertEqual(self._ids(accountOwner=7), [str(match.id)])++ @parameterized.expand(+ [+ ("absent_keys", {"_properties": {}}),+ ("null_valued_keys", {"properties": {}}),+ ]+ )+ def test_all_roles_unassigned(self, _name, unassigned_kwargs):+ create_account(team_id=self.team.id, name="Has CSM", properties={"csm": {"id": 7, "email": "[email protected]"}})+ unassigned = create_account(team_id=self.team.id, name="Unassigned", **unassigned_kwargs)+ self.assertEqual(self._ids(allRolesUnassigned=True), [str(unassigned.id)])++ def test_combined_role_and_tags(self):+ enterprise_tag = Tag.objects.create(name="enterprise", team=self.team)+ startup_tag = Tag.objects.create(name="startup", team=self.team)++ match = create_account(team_id=self.team.id, name="A", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ match.tagged_items.create(tag=enterprise_tag)++ wrong_tag = create_account(team_id=self.team.id, name="B", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ wrong_tag.tagged_items.create(tag=startup_tag)++ wrong_csm = create_account(team_id=self.team.id, name="C", _properties={"csm": {"id": 8, "email": "[email protected]"}})+ wrong_csm.tagged_items.create(tag=enterprise_tag)++ self.assertEqual(self._ids(csm=7, tagNames=["enterprise"]), [str(match.id)])++ def test_role_filter_respects_team_isolation(self):+ other_team = Team.objects.create(organization=self.organization)+ create_account(team_id=other_team.id, name="Theirs", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ mine = create_account(team_id=self.team.id, name="Mine", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ self.assertEqual(self._ids(csm=7), [str(mine.id)])++ def test_ordering_by_name_asc(self):+ banana = create_account(team_id=self.team.id, name="Banana")+ apple = create_account(team_id=self.team.id, name="Apple")+ self.assertEqual(self._ids(orderBy=["name"]), [str(apple.id), str(banana.id)])++ def test_ordering_by_name_desc(self):+ apple = create_account(team_id=self.team.id, name="Apple")+ banana = create_account(team_id=self.team.id, name="Banana")+ self.assertEqual(self._ids(orderBy=["-name"]), [str(banana.id), str(apple.id)])++ def test_pagination_limit_and_offset(self):+ ids = [str(create_account(team_id=self.team.id, name=f"Account {i:02d}").id) for i in range(5)]+ expected_reverse = list(reversed(ids))++ page_one_runner, page_one_response = self._run_query(limit=2, offset=0)+ self.assertTrue(page_one_response.hasMore)+ id_idx = page_one_runner.columns.index("id")+ self.assertEqual(+ [str(row[id_idx]) for row in page_one_response.results],+ expected_reverse[:2],+ )++ page_three_runner, page_three_response = self._run_query(limit=2, offset=4)+ self.assertFalse(page_three_response.hasMore)+ id_idx = page_three_runner.columns.index("id")+ self.assertEqual(+ [str(row[id_idx]) for row in page_three_response.results],+ expected_reverse[4:],+ )++ def test_empty_result_set(self):+ create_account(team_id=self.team.id, name="Acme")+ _, response = self._run_query(search="nonexistent_substring_xyz")+ self.assertEqual(response.results, [])+ self.assertFalse(response.hasMore)+ self.assertEqual(response.offset, 0)++ def test_external_id_is_in_default_columns(self):+ create_account(team_id=self.team.id, name="A", external_id="ext-A")+ runner = AccountsQueryRunner(query=AccountsQuery(), team=self.team)+ self.assertIn("external_id", runner.columns)++ def test_set_tags_on_object_helper_matches(self):+ # Mirror existing API test setup that uses set_tags_on_object.+ account = create_account(team_id=self.team.id, name="A", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ set_tags_on_object(["enterprise"], account)+ self.assertEqual(self._ids(csm=7, tagNames=["enterprise"]), [str(account.id)])++ def test_custom_select_uses_only_requested_columns(self):+ create_account(team_id=self.team.id, name="A")+ runner = AccountsQueryRunner(query=AccountsQuery(select=["id", "name"]), team=self.team)+ response = runner.calculate()+ self.assertEqual(runner.columns, ["id", "name"])+ self.assertEqual(len(response.results[0]), 2)++ def test_custom_select_deduplicates(self):+ create_account(team_id=self.team.id, name="A")+ runner = AccountsQueryRunner(query=AccountsQuery(select=["id", "name", "id"]), team=self.team)+ self.assertEqual(runner.columns, ["id", "name"])++ def test_validate_query_runner_access_default(self):+ runner = AccountsQueryRunner(query=AccountsQuery(), team=self.team)+ self.assertTrue(runner.validate_query_runner_access(self.user))++ def test_validate_query_runner_access_denied(self):+ AccessControl.objects.create(team=self.team, resource="customer_analytics", access_level="none")+ self.organization.available_product_features.append({"key": AvailableFeature.ACCESS_CONTROL}) # type: ignore[union-attr]+ self.organization.save()++ runner = AccountsQueryRunner(query=AccountsQuery(), team=self.team)+ self.assertRaises(UserAccessControlError, runner.validate_query_runner_access, self.user)diff --git a/products/customer_analytics/backend/test/factories.py b/products/customer_analytics/backend/test/factories.pynew file mode 100644index 000000000000..8d816a9b16ee--- /dev/null+++ b/products/customer_analytics/backend/test/factories.py@@ -0,0 +1,8 @@+from typing import Any++from products.customer_analytics.backend.models import Account+++def create_account(*, team_id: int, name: str = "Acme Corp", **kwargs: Any) -> Account:+ """Create an Account for tests. Always supplies `team_id` to make team-isolation cases ergonomic."""+ return Account.objects.unscoped().create(team_id=team_id, name=name, **kwargs)diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 6dd3229f3cb4..01a089a61f12 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -4162,6 +4162,30 @@ export interface Response26Api {warnings?: DataWarehouseSyncWarningApi[] | null}+export interface Response27Api {+ columns: unknown[]+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null+ hasMore?: boolean | null+ /** Generated HogQL query. */+ hogql: string+ kind?: 'AccountsQuery'+ limit: number+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiersApi | null+ offset: number+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatusApi | null+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponseApi | null+ results: unknown[][]+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTimingApi[] | null+ types: string[]+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarningApi[] | null+}+export type TaxonomicFilterGroupTypeApi = (typeof TaxonomicFilterGroupTypeApi)[keyof typeof TaxonomicFilterGroupTypeApi]export const TaxonomicFilterGroupTypeApi = {@@ -6824,6 +6848,50 @@ export interface EndpointsUsageTableQueryApi {version?: number | null}+export interface AccountsQueryResponseApi {+ columns: unknown[]+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null+ hasMore?: boolean | null+ /** Generated HogQL query. */+ hogql: string+ kind?: 'AccountsQuery'+ limit: number+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiersApi | null+ offset: number+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatusApi | null+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponseApi | null+ results: unknown[][]+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTimingApi[] | null+ types: string[]+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarningApi[] | null+}++export interface AccountsQueryApi {+ accountExecutive?: string | number | null+ accountOwner?: string | number | null+ allRolesUnassigned?: boolean | null+ csm?: string | number | null+ kind?: 'AccountsQuery'+ limit?: number | null+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiersApi | null+ offset?: number | null+ orderBy?: string[] | null+ response?: AccountsQueryResponseApi | null+ search?: string | null+ select?: string[] | null+ tagNames?: string[] | null+ tags?: QueryLogTagsApi | null+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type DataTableNodeApiResponse =| { [key: string]: unknown }| ResponseApi@@ -6852,6 +6920,7 @@ export type DataTableNodeApiResponse =| Response24Api| Response25Api| Response26Api+ | Response27Api| nullexport interface DataTableNodeApi {@@ -6958,6 +7027,7 @@ export interface DataTableNodeApi {| TracesQueryApi| TraceQueryApi| EndpointsUsageTableQueryApi+ | AccountsQueryApitags?: QueryLogTagsApi | null/** version of the node, used for schema migrations */version?: number | nulldiff --git a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambrindex e4feb4ba231a..940ec82dc21a 100644--- a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr+++ b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr@@ -110,7 +110,7 @@This is a list of all the available tables in the database:```- ['events', 'groups', 'persons', 'sessions', 'logs', 'query_log', 'system.accounts', 'system.activity_logs', 'system.actions', 'system.alerts', 'system.annotations', 'system.batch_export_backfills', 'system.batch_exports', 'system.cohort_calculation_history', 'system.cohorts', 'system.dashboards', 'system.dashboard_tiles', 'system.data_modeling_jobs', 'system.data_modeling_views', 'system.data_modeling_endpoint_versions', 'system.data_modeling_endpoints', 'system.data_warehouse_sources', 'system.data_warehouse_tables', 'system.error_tracking_assignment_rules', 'system.error_tracking_issue_assignments', 'system.error_tracking_issue_fingerprints', 'system.error_tracking_issues', 'system.error_tracking_releases', 'system.error_tracking_symbol_sets', 'system.error_tracking_suppression_rules', 'system.early_access_features', 'system.experiments', 'system.exports', 'system.feature_flags', 'system.groups', 'system.group_type_mappings', 'system.hog_flows', 'system.hog_functions', 'system.ingestion_warnings', 'system.integrations', 'system.integration_repository_cache', 'system.insight_variables', 'system.logs_alerts', 'system.logs_views', 'system.insights', 'system.notebooks', 'system.sandbox_environments', 'system.review_queue_items', 'system.review_queues', 'system.score_definitions', 'system.session_recording_playlists', 'system.session_recordings', 'system.source_schemas', 'system.source_sync_jobs', 'system.support_tickets', 'system.surveys', 'system.task_runs', 'system.tasks', 'system.teams', 'system.trace_review_scores', 'system.trace_reviews', 'system.usage_metrics']+ ['events', 'groups', 'persons', 'sessions', 'logs', 'query_log', 'system.accounts', 'system.activity_logs', 'system.actions', 'system.alerts', 'system.annotations', 'system.batch_export_backfills', 'system.batch_exports', 'system.cohort_calculation_history', 'system.cohorts', 'system.dashboards', 'system.dashboard_tiles', 'system.data_modeling_jobs', 'system.data_modeling_views', 'system.data_modeling_endpoint_versions', 'system.data_modeling_endpoints', 'system.data_warehouse_sources', 'system.data_warehouse_tables', 'system.error_tracking_assignment_rules', 'system.error_tracking_issue_assignments', 'system.error_tracking_issue_fingerprints', 'system.error_tracking_issues', 'system.error_tracking_releases', 'system.error_tracking_symbol_sets', 'system.error_tracking_suppression_rules', 'system.early_access_features', 'system.experiments', 'system.exports', 'system.feature_flags', 'system.groups', 'system.group_type_mappings', 'system.hog_flows', 'system.hog_functions', 'system.ingestion_warnings', 'system.integrations', 'system.integration_repository_cache', 'system.insight_variables', 'system.logs_alerts', 'system.logs_views', 'system.insights', 'system.notebooks', 'system.sandbox_environments', 'system.review_queue_items', 'system.review_queues', 'system.score_definitions', 'system.session_recording_playlists', 'system.session_recordings', 'system.source_schemas', 'system.source_sync_jobs', 'system.support_tickets', 'system.surveys', 'system.task_runs', 'system.tags', 'system.tasks', 'system.teams', 'system.trace_review_scores', 'system.trace_reviews', 'system.usage_metrics']````person` or `event` metadata unspecified above (emails, names, etc.) is stored in `properties` fields, accessed like: `properties.foo.bar`.diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 7d41fc679355..01de5da1d932 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -3869,6 +3869,30 @@ export interface Response26Api {warnings?: DataWarehouseSyncWarningApi[] | null}+export interface Response27Api {+ columns: unknown[]+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null+ hasMore?: boolean | null+ /** Generated HogQL query. */+ hogql: string+ kind?: 'AccountsQuery'+ limit: number+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiersApi | null+ offset: number+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatusApi | null+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponseApi | null+ results: unknown[][]+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTimingApi[] | null+ types: string[]+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarningApi[] | null+}+export type TaxonomicFilterGroupTypeApi = (typeof TaxonomicFilterGroupTypeApi)[keyof typeof TaxonomicFilterGroupTypeApi]export const TaxonomicFilterGroupTypeApi = {@@ -6531,6 +6555,50 @@ export interface EndpointsUsageTableQueryApi {version?: number | null}+export interface AccountsQueryResponseApi {+ columns: unknown[]+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null+ hasMore?: boolean | null+ /** Generated HogQL query. */+ hogql: string+ kind?: 'AccountsQuery'+ limit: number+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiersApi | null+ offset: number+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatusApi | null+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponseApi | null+ results: unknown[][]+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTimingApi[] | null+ types: string[]+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarningApi[] | null+}++export interface AccountsQueryApi {+ accountExecutive?: string | number | null+ accountOwner?: string | number | null+ allRolesUnassigned?: boolean | null+ csm?: string | number | null+ kind?: 'AccountsQuery'+ limit?: number | null+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiersApi | null+ offset?: number | null+ orderBy?: string[] | null+ response?: AccountsQueryResponseApi | null+ search?: string | null+ select?: string[] | null+ tagNames?: string[] | null+ tags?: QueryLogTagsApi | null+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type DataTableNodeApiResponse =| { [key: string]: unknown }| ResponseApi@@ -6559,6 +6627,7 @@ export type DataTableNodeApiResponse =| Response24Api| Response25Api| Response26Api+ | Response27Api| nullexport interface DataTableNodeApi {@@ -6665,6 +6734,7 @@ export interface DataTableNodeApi {| TracesQueryApi| TraceQueryApi| EndpointsUsageTableQueryApi+ | AccountsQueryApitags?: QueryLogTagsApi | null/** version of the node, used for schema migrations */version?: number | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex ec366d057fe8..257d13dab0c9 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -200,6 +200,323 @@ export namespace Schemas {readonly last_modified_by: UserBasic;}+ export type BounceRatePageViewMode = typeof BounceRatePageViewMode[keyof typeof BounceRatePageViewMode];+++ export const BounceRatePageViewMode = {+ CountPageviews: 'count_pageviews',+ UniqUrls: 'uniq_urls',+ UniqPageScreenAutocaptures: 'uniq_page_screen_autocaptures',+ } as const;++ export type FilterLogicalOperator = typeof FilterLogicalOperator[keyof typeof FilterLogicalOperator];+++ export const FilterLogicalOperator = {+ And: 'AND',+ Or: 'OR',+ } as const;++ export type CustomChannelField = typeof CustomChannelField[keyof typeof CustomChannelField];+++ export const CustomChannelField = {+ UtmSource: 'utm_source',+ UtmMedium: 'utm_medium',+ UtmCampaign: 'utm_campaign',+ ReferringDomain: 'referring_domain',+ Url: 'url',+ Pathname: 'pathname',+ Hostname: 'hostname',+ } as const;++ export type CustomChannelOperator = typeof CustomChannelOperator[keyof typeof CustomChannelOperator];+++ export const CustomChannelOperator = {+ Exact: 'exact',+ IsNot: 'is_not',+ IsSet: 'is_set',+ IsNotSet: 'is_not_set',+ Icontains: 'icontains',+ NotIcontains: 'not_icontains',+ Regex: 'regex',+ NotRegex: 'not_regex',+ } as const;++ export interface CustomChannelCondition {+ id: string;+ key: CustomChannelField;+ op: CustomChannelOperator;+ value?: string | string[] | null;+ }++ export interface CustomChannelRule {+ channel_type: string;+ combiner: FilterLogicalOperator;+ id: string;+ items: CustomChannelCondition[];+ }++ export interface DataWarehouseEventsModifier {+ distinct_id_field: string;+ id_field: string;+ table_name: string;+ timestamp_field: string;+ }++ export type InCohortVia = typeof InCohortVia[keyof typeof InCohortVia];+++ export const InCohortVia = {+ Auto: 'auto',+ Leftjoin: 'leftjoin',+ Subquery: 'subquery',+ LeftjoinConjoined: 'leftjoin_conjoined',+ } as const;++ export type InlineCohortCalculation = typeof InlineCohortCalculation[keyof typeof InlineCohortCalculation];+++ export const InlineCohortCalculation = {+ Off: 'off',+ Auto: 'auto',+ Always: 'always',+ } as const;++ export type MaterializationMode = typeof MaterializationMode[keyof typeof MaterializationMode];+++ export const MaterializationMode = {+ Auto: 'auto',+ LegacyNullAsString: 'legacy_null_as_string',+ LegacyNullAsNull: 'legacy_null_as_null',+ Disabled: 'disabled',+ } as const;++ export type MaterializedColumnsOptimizationMode = typeof MaterializedColumnsOptimizationMode[keyof typeof MaterializedColumnsOptimizationMode];+++ export const MaterializedColumnsOptimizationMode = {+ Disabled: 'disabled',+ Optimized: 'optimized',+ } as const;++ export type ParserMode = typeof ParserMode[keyof typeof ParserMode];+++ export const ParserMode = {+ CppOnly: 'cpp_only',+ CppWithRustShadow: 'cpp_with_rust_shadow',+ CppWithRustPyShadow: 'cpp_with_rust_py_shadow',+ RustWithCppShadow: 'rust_with_cpp_shadow',+ RustOnly: 'rust_only',+ RustPyOnly: 'rust_py_only',+ RustPyWithCppShadow: 'rust_py_with_cpp_shadow',+ } as const;++ export type PersonsArgMaxVersion = typeof PersonsArgMaxVersion[keyof typeof PersonsArgMaxVersion];+++ export const PersonsArgMaxVersion = {+ Auto: 'auto',+ V1: 'v1',+ V2: 'v2',+ } as const;++ export type PersonsJoinMode = typeof PersonsJoinMode[keyof typeof PersonsJoinMode];+++ export const PersonsJoinMode = {+ Inner: 'inner',+ Left: 'left',+ } as const;++ export type PersonsOnEventsMode = typeof PersonsOnEventsMode[keyof typeof PersonsOnEventsMode];+++ export const PersonsOnEventsMode = {+ Disabled: 'disabled',+ PersonIdNoOverridePropertiesOnEvents: 'person_id_no_override_properties_on_events',+ PersonIdOverridePropertiesOnEvents: 'person_id_override_properties_on_events',+ PersonIdOverridePropertiesJoined: 'person_id_override_properties_joined',+ } as const;++ export type PropertyGroupsMode = typeof PropertyGroupsMode[keyof typeof PropertyGroupsMode];+++ export const PropertyGroupsMode = {+ Enabled: 'enabled',+ Disabled: 'disabled',+ Optimized: 'optimized',+ } as const;++ export type SessionTableVersion = typeof SessionTableVersion[keyof typeof SessionTableVersion];+++ export const SessionTableVersion = {+ Auto: 'auto',+ V1: 'v1',+ V2: 'v2',+ V3: 'v3',+ } as const;++ export type SessionsV2JoinMode = typeof SessionsV2JoinMode[keyof typeof SessionsV2JoinMode];+++ export const SessionsV2JoinMode = {+ String: 'string',+ Uuid: 'uuid',+ } as const;++ export interface HogQLQueryModifiers {+ bounceRateDurationSeconds?: number | null;+ bounceRatePageViewMode?: BounceRatePageViewMode | null;+ convertToProjectTimezone?: boolean | null;+ customChannelTypeRules?: CustomChannelRule[] | null;+ dataWarehouseEventsModifiers?: DataWarehouseEventsModifier[] | null;+ debug?: boolean | null;+ /** If these are provided, the query will fail if these skip indexes are not used */+ forceClickhouseDataSkippingIndexes?: string[] | null;+ formatCsvAllowDoubleQuotes?: boolean | null;+ inCohortVia?: InCohortVia | null;+ inlineCohortCalculation?: InlineCohortCalculation | null;+ materializationMode?: MaterializationMode | null;+ materializedColumnsOptimizationMode?: MaterializedColumnsOptimizationMode | null;+ optimizeJoinedFilters?: boolean | null;+ optimizeProjections?: boolean | null;+ /** HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */+ parserMode?: ParserMode | null;+ personsArgMaxVersion?: PersonsArgMaxVersion | null;+ personsJoinMode?: PersonsJoinMode | null;+ personsOnEventsMode?: PersonsOnEventsMode | null;+ propertyGroupsMode?: PropertyGroupsMode | null;+ s3TableUseInvalidColumns?: boolean | null;+ /** Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter. */+ sessionIdPushdown?: boolean | null;+ /** Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`). */+ sessionPropertyPreAggregation?: boolean | null;+ sessionTableVersion?: SessionTableVersion | null;+ sessionsV2JoinMode?: SessionsV2JoinMode | null;+ timings?: boolean | null;+ useMaterializedViews?: boolean | null;+ usePreaggregatedIntermediateResults?: boolean | null;+ /** Try to automatically convert HogQL queries to use preaggregated tables at the AST level * */+ usePreaggregatedTableTransforms?: boolean | null;+ useWebAnalyticsPreAggregatedTables?: boolean | null;+ }++ export interface ClickhouseQueryProgress {+ active_cpu_time: number;+ bytes_read: number;+ estimated_rows_total: number;+ rows_read: number;+ time_elapsed: number;+ }++ export interface QueryStatus {+ /** Whether the query is still running. Will be true if the query is complete, even if it errored. Either result or error will be set. */+ complete?: boolean | null;+ dashboard_id?: number | null;+ /** When did the query execution task finish (whether successfully or not). */+ end_time?: string | null;+ /** If the query failed, this will be set to true. More information can be found in the error_message field. */+ error?: boolean | null;+ error_message?: string | null;+ expiration_time?: string | null;+ id: string;+ insight_id?: number | null;+ labels?: string[] | null;+ /** When was the query execution task picked up by a worker. */+ pickup_time?: string | null;+ /** ONLY async queries use QueryStatus. */+ query_async?: true;+ query_progress?: ClickhouseQueryProgress | null;+ results?: unknown;+ /** When was query execution task enqueued. */+ start_time?: string | null;+ task_id?: string | null;+ team_id: number;+ }++ export interface ResolvedDateRangeResponse {+ date_from: string;+ date_to: string;+ }++ export interface QueryTiming {+ /** Key. Shortened to 'k' to save on data. */+ k: string;+ /** Time in seconds. Shortened to 't' to save on data. */+ t: number;+ }++ export interface DataWarehouseSyncWarning {+ /** Human-readable warning shown to the user */+ message: string;+ /** Name of the ExternalDataSchema responsible for syncing the table */+ schema_name: string;+ /** Source type, e.g. "Stripe", "Hubspot" */+ source_type: string;+ /** Sync status that triggered the warning, e.g. "Failed", "Paused", "BillingLimitReached" */+ status: string;+ /** Name of the warehouse table the warning refers to */+ table_name: string;+ }++ export interface AccountsQueryResponse {+ columns: unknown[];+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null;+ hasMore?: boolean | null;+ /** Generated HogQL query. */+ hogql: string;+ kind?: 'AccountsQuery';+ limit: number;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ offset: number;+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatus | null;+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponse | null;+ results: unknown[][];+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTiming[] | null;+ types: string[];+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarning[] | null;+ }++ export interface QueryLogTags {+ /** Name of the query, preferably unique. For example web_analytics_vitals */+ name?: string | null;+ /** Product responsible for this query. Use string, there's no need to churn the Schema when we add a new product * */+ productKey?: string | null;+ /** Scene where this query is shown in the UI. Use string, there's no need to churn the Schema when we add a new Scene * */+ scene?: string | null;+ }++ export interface AccountsQuery {+ accountExecutive?: string | number | null;+ accountOwner?: string | number | null;+ allRolesUnassigned?: boolean | null;+ csm?: string | number | null;+ kind?: 'AccountsQuery';+ limit?: number | null;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ offset?: number | null;+ orderBy?: string[] | null;+ response?: AccountsQueryResponse | null;+ search?: string | null;+ select?: string[] | null;+ tagNames?: string[] | null;+ tags?: QueryLogTags | null;+ /** version of the node, used for schema migrations */+ version?: number | null;+ }+/*** * `event` - event* `event_metadata` - event_metadata@@ -1398,275 +1715,11 @@ export namespace Schemas {total_count: number;}- export type BounceRatePageViewMode = typeof BounceRatePageViewMode[keyof typeof BounceRatePageViewMode];--- export const BounceRatePageViewMode = {- CountPageviews: 'count_pageviews',- UniqUrls: 'uniq_urls',- UniqPageScreenAutocaptures: 'uniq_page_screen_autocaptures',- } as const;-- export type FilterLogicalOperator = typeof FilterLogicalOperator[keyof typeof FilterLogicalOperator];--- export const FilterLogicalOperator = {- And: 'AND',- Or: 'OR',- } as const;-- export type CustomChannelField = typeof CustomChannelField[keyof typeof CustomChannelField];--- export const CustomChannelField = {- UtmSource: 'utm_source',- UtmMedium: 'utm_medium',- UtmCampaign: 'utm_campaign',- ReferringDomain: 'referring_domain',- Url: 'url',- Pathname: 'pathname',- Hostname: 'hostname',- } as const;-- export type CustomChannelOperator = typeof CustomChannelOperator[keyof typeof CustomChannelOperator];--- export const CustomChannelOperator = {- Exact: 'exact',- IsNot: 'is_not',- IsSet: 'is_set',- IsNotSet: 'is_not_set',- Icontains: 'icontains',- NotIcontains: 'not_icontains',- Regex: 'regex',- NotRegex: 'not_regex',- } as const;-- export interface CustomChannelCondition {- id: string;- key: CustomChannelField;- op: CustomChannelOperator;- value?: string | string[] | null;- }-- export interface CustomChannelRule {- channel_type: string;- combiner: FilterLogicalOperator;- id: string;- items: CustomChannelCondition[];- }-- export interface DataWarehouseEventsModifier {- distinct_id_field: string;- id_field: string;- table_name: string;- timestamp_field: string;- }-- export type InCohortVia = typeof InCohortVia[keyof typeof InCohortVia];--- export const InCohortVia = {- Auto: 'auto',- Leftjoin: 'leftjoin',- Subquery: 'subquery',- LeftjoinConjoined: 'leftjoin_conjoined',- } as const;-- export type InlineCohortCalculation = typeof InlineCohortCalculation[keyof typeof InlineCohortCalculation];--- export const InlineCohortCalculation = {- Off: 'off',- Auto: 'auto',- Always: 'always',- } as const;-- export type MaterializationMode = typeof MaterializationMode[keyof typeof MaterializationMode];--- export const MaterializationMode = {- Auto: 'auto',- LegacyNullAsString: 'legacy_null_as_string',- LegacyNullAsNull: 'legacy_null_as_null',- Disabled: 'disabled',- } as const;-- export type MaterializedColumnsOptimizationMode = typeof MaterializedColumnsOptimizationMode[keyof typeof MaterializedColumnsOptimizationMode];--- export const MaterializedColumnsOptimizationMode = {- Disabled: 'disabled',- Optimized: 'optimized',- } as const;-- export type ParserMode = typeof ParserMode[keyof typeof ParserMode];--- export const ParserMode = {- CppOnly: 'cpp_only',- CppWithRustShadow: 'cpp_with_rust_shadow',- CppWithRustPyShadow: 'cpp_with_rust_py_shadow',- RustWithCppShadow: 'rust_with_cpp_shadow',- RustOnly: 'rust_only',- RustPyOnly: 'rust_py_only',- RustPyWithCppShadow: 'rust_py_with_cpp_shadow',- } as const;-- export type PersonsArgMaxVersion = typeof PersonsArgMaxVersion[keyof typeof PersonsArgMaxVersion];--- export const PersonsArgMaxVersion = {- Auto: 'auto',- V1: 'v1',- V2: 'v2',- } as const;-- export type PersonsJoinMode = typeof PersonsJoinMode[keyof typeof PersonsJoinMode];--- export const PersonsJoinMode = {- Inner: 'inner',- Left: 'left',- } as const;-- export type PersonsOnEventsMode = typeof PersonsOnEventsMode[keyof typeof PersonsOnEventsMode];--- export const PersonsOnEventsMode = {- Disabled: 'disabled',- PersonIdNoOverridePropertiesOnEvents: 'person_id_no_override_properties_on_events',- PersonIdOverridePropertiesOnEvents: 'person_id_override_properties_on_events',- PersonIdOverridePropertiesJoined: 'person_id_override_properties_joined',- } as const;-- export type PropertyGroupsMode = typeof PropertyGroupsMode[keyof typeof PropertyGroupsMode];--- export const PropertyGroupsMode = {- Enabled: 'enabled',- Disabled: 'disabled',- Optimized: 'optimized',- } as const;-- export type SessionTableVersion = typeof SessionTableVersion[keyof typeof SessionTableVersion];--- export const SessionTableVersion = {- Auto: 'auto',- V1: 'v1',- V2: 'v2',- V3: 'v3',- } as const;-- export type SessionsV2JoinMode = typeof SessionsV2JoinMode[keyof typeof SessionsV2JoinMode];--- export const SessionsV2JoinMode = {- String: 'string',- Uuid: 'uuid',- } as const;-- export interface HogQLQueryModifiers {- bounceRateDurationSeconds?: number | null;- bounceRatePageViewMode?: BounceRatePageViewMode | null;- convertToProjectTimezone?: boolean | null;- customChannelTypeRules?: CustomChannelRule[] | null;- dataWarehouseEventsModifiers?: DataWarehouseEventsModifier[] | null;- debug?: boolean | null;- /** If these are provided, the query will fail if these skip indexes are not used */- forceClickhouseDataSkippingIndexes?: string[] | null;- formatCsvAllowDoubleQuotes?: boolean | null;- inCohortVia?: InCohortVia | null;- inlineCohortCalculation?: InlineCohortCalculation | null;- materializationMode?: MaterializationMode | null;- materializedColumnsOptimizationMode?: MaterializedColumnsOptimizationMode | null;- optimizeJoinedFilters?: boolean | null;- optimizeProjections?: boolean | null;- /** HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */- parserMode?: ParserMode | null;- personsArgMaxVersion?: PersonsArgMaxVersion | null;- personsJoinMode?: PersonsJoinMode | null;- personsOnEventsMode?: PersonsOnEventsMode | null;- propertyGroupsMode?: PropertyGroupsMode | null;- s3TableUseInvalidColumns?: boolean | null;- /** Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter. */- sessionIdPushdown?: boolean | null;- /** Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`). */- sessionPropertyPreAggregation?: boolean | null;- sessionTableVersion?: SessionTableVersion | null;- sessionsV2JoinMode?: SessionsV2JoinMode | null;- timings?: boolean | null;- useMaterializedViews?: boolean | null;- usePreaggregatedIntermediateResults?: boolean | null;- /** Try to automatically convert HogQL queries to use preaggregated tables at the AST level * */- usePreaggregatedTableTransforms?: boolean | null;- useWebAnalyticsPreAggregatedTables?: boolean | null;- }-- export interface ClickhouseQueryProgress {- active_cpu_time: number;- bytes_read: number;- estimated_rows_total: number;- rows_read: number;- time_elapsed: number;- }-- export interface QueryStatus {- /** Whether the query is still running. Will be true if the query is complete, even if it errored. Either result or error will be set. */- complete?: boolean | null;- dashboard_id?: number | null;- /** When did the query execution task finish (whether successfully or not). */- end_time?: string | null;- /** If the query failed, this will be set to true. More information can be found in the error_message field. */- error?: boolean | null;- error_message?: string | null;- expiration_time?: string | null;- id: string;- insight_id?: number | null;- labels?: string[] | null;- /** When was the query execution task picked up by a worker. */- pickup_time?: string | null;- /** ONLY async queries use QueryStatus. */- query_async?: true;- query_progress?: ClickhouseQueryProgress | null;- results?: unknown;- /** When was query execution task enqueued. */- start_time?: string | null;- task_id?: string | null;- team_id: number;- }-- export interface ResolvedDateRangeResponse {- date_from: string;- date_to: string;- }-export interface ActorsPropertyTaxonomyResponse {sample_count: number;sample_values: (string | number | boolean)[];}- export interface QueryTiming {- /** Key. Shortened to 'k' to save on data. */- k: string;- /** Time in seconds. Shortened to 't' to save on data. */- t: number;- }-- export interface DataWarehouseSyncWarning {- /** Human-readable warning shown to the user */- message: string;- /** Name of the ExternalDataSchema responsible for syncing the table */- schema_name: string;- /** Source type, e.g. "Stripe", "Hubspot" */- source_type: string;- /** Sync status that triggered the warning, e.g. "Failed", "Paused", "BillingLimitReached" */- status: string;- /** Name of the warehouse table the warning refers to */- table_name: string;- }-export interface ActorsPropertyTaxonomyQueryResponse {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -1685,15 +1738,6 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryLogTags {- /** Name of the query, preferably unique. For example web_analytics_vitals */- name?: string | null;- /** Product responsible for this query. Use string, there's no need to churn the Schema when we add a new product * */- productKey?: string | null;- /** Scene where this query is shown in the UI. Use string, there's no need to churn the Schema when we add a new Scene * */- scene?: string | null;- }-export interface ActorsPropertyTaxonomyQuery {groupTypeIndex?: number | null;kind?: 'ActorsPropertyTaxonomyQuery';@@ -10107,6 +10151,30 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}+ export interface Response27 {+ columns: unknown[];+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null;+ hasMore?: boolean | null;+ /** Generated HogQL query. */+ hogql: string;+ kind?: 'AccountsQuery';+ limit: number;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ offset: number;+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatus | null;+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponse | null;+ results: unknown[][];+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTiming[] | null;+ types: string[];+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarning[] | null;+ }+export type TaxonomicFilterGroupType = typeof TaxonomicFilterGroupType[keyof typeof TaxonomicFilterGroupType];@@ -11504,7 +11572,7 @@ export namespace Schemas {version?: number | null;}- export type DataTableNodeResponse = { [key: string]: unknown } | Response | Response1 | Response2 | Response3 | Response4 | Response5 | Response6 | Response7 | Response8 | Response9 | Response10 | Response11 | Response12 | Response13 | Response14 | Response15 | Response16 | Response18 | Response19 | Response20 | Response21 | Response22 | Response23 | Response24 | Response25 | Response26 | null;+ export type DataTableNodeResponse = { [key: string]: unknown } | Response | Response1 | Response2 | Response3 | Response4 | Response5 | Response6 | Response7 | Response8 | Response9 | Response10 | Response11 | Response12 | Response13 | Response14 | Response15 | Response16 | Response18 | Response19 | Response20 | Response21 | Response22 | Response23 | Response24 | Response25 | Response26 | Response27 | null;export interface DataTableNode {/** Can the user click on column headers to sort the table? (default: true) */@@ -11578,7 +11646,7 @@ export namespace Schemas {/** Show a detailed query timing breakdown */showTimings?: boolean | null;/** Source of the events */- source: EventsNode | EventsQuery | PersonsNode | ActorsQuery | GroupsQuery | HogQLQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | SessionAttributionExplorerQuery | SessionsQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | ErrorTrackingQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | TracesQuery | TraceQuery | EndpointsUsageTableQuery;+ source: EventsNode | EventsQuery | PersonsNode | ActorsQuery | GroupsQuery | HogQLQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | SessionAttributionExplorerQuery | SessionsQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | ErrorTrackingQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | TracesQuery | TraceQuery | EndpointsUsageTableQuery | AccountsQuery;tags?: QueryLogTags | null;/** version of the node, used for schema migrations */version?: number | null;@@ -19863,7 +19931,7 @@ export namespace Schemas {query: string;response?: HogQLMetadataResponse | null;/** Query within which "expr" and "template" are validated. Defaults to "select * from events" */- sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebTrendsQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | null;+ sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebTrendsQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | null;tags?: QueryLogTags | null;/** Variables to be subsituted into the query */variables?: HogQLMetadataVariables;@@ -19889,7 +19957,7 @@ export namespace Schemas {query: string;response?: HogQLAutocompleteResponse | null;/** Query in whose context to validate. */- sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebTrendsQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | null;+ sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebTrendsQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | null;/** Start position of the editor word */startPosition: number;tags?: QueryLogTags | null;@@ -33775,7 +33843,7 @@ export namespace Schemas {```For more details on HogQL queries, see the [PostHog HogQL documentation](/docs/hogql#api-access). */- query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | PropertyValuesQuery;+ query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | PropertyValuesQuery;/** Whether results should be calculated sync or async, and how much to rely on the cache:- `'blocking'` - calculate synchronously (returning only when the query is done), UNLESS there are very fresh results in the cache- `'async'` - kick off background calculation (returning immediately with a query status), UNLESS there are very fresh results in the cache@@ -35094,9 +35162,33 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export type QueryResponseAlternative66ResultsItem = { [key: string]: unknown };-export interface QueryResponseAlternative66 {+ columns: unknown[];+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null;+ hasMore?: boolean | null;+ /** Generated HogQL query. */+ hogql: string;+ kind?: 'AccountsQuery';+ limit: number;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ offset: number;+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatus | null;+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponse | null;+ results: unknown[][];+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTiming[] | null;+ types: string[];+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarning[] | null;+ }++ export type QueryResponseAlternative67ResultsItem = { [key: string]: unknown };++ export interface QueryResponseAlternative67 {boxplot_data?: BoxPlotDatum[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -35110,14 +35202,14 @@ export namespace Schemas {query_status?: QueryStatus | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: QueryResponseAlternative66ResultsItem[];+ results: QueryResponseAlternative67ResultsItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative67 {+ export interface QueryResponseAlternative68 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35135,7 +35227,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative68 {+ export interface QueryResponseAlternative69 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35153,7 +35245,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative69 {+ export interface QueryResponseAlternative70 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35171,9 +35263,9 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export type QueryResponseAlternative70ResultsItem = { [key: string]: unknown };+ export type QueryResponseAlternative71ResultsItem = { [key: string]: unknown };- export interface QueryResponseAlternative70 {+ export interface QueryResponseAlternative71 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35184,14 +35276,14 @@ export namespace Schemas {query_status?: QueryStatus | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: QueryResponseAlternative70ResultsItem[];+ results: QueryResponseAlternative71ResultsItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative72 {+ export interface QueryResponseAlternative73 {columns?: unknown[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -35214,14 +35306,14 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export type QueryResponseAlternative73Tables = {[key: string]: DatabaseSchemaPostHogTable | DatabaseSchemaSystemTable | DatabaseSchemaDataWarehouseTable | DatabaseSchemaViewTable | DatabaseSchemaManagedViewTable | DatabaseSchemaBatchExportTable | DatabaseSchemaMaterializedViewTable | DatabaseSchemaEndpointTable};+ export type QueryResponseAlternative74Tables = {[key: string]: DatabaseSchemaPostHogTable | DatabaseSchemaSystemTable | DatabaseSchemaDataWarehouseTable | DatabaseSchemaViewTable | DatabaseSchemaManagedViewTable | DatabaseSchemaBatchExportTable | DatabaseSchemaMaterializedViewTable | DatabaseSchemaEndpointTable};- export interface QueryResponseAlternative73 {+ export interface QueryResponseAlternative74 {joins: DataWarehouseViewLink[];- tables: QueryResponseAlternative73Tables;+ tables: QueryResponseAlternative74Tables;}- export interface QueryResponseAlternative74 {+ export interface QueryResponseAlternative75 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;has_next: boolean;@@ -35242,7 +35334,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative75 {+ export interface QueryResponseAlternative76 {columns?: string[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -35266,7 +35358,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative76 {+ export interface QueryResponseAlternative77 {count: number;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -35285,7 +35377,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative77 {+ export interface QueryResponseAlternative78 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35303,7 +35395,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative78 {+ export interface QueryResponseAlternative79 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;hasMore?: boolean | null;@@ -35326,7 +35418,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative79 {+ export interface QueryResponseAlternative80 {/** Result rows for the comparison period when `compareFilter.compare` is true. */compare?: AggregatedSpanRow[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */@@ -35346,7 +35438,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative80 {+ export interface QueryResponseAlternative81 {/** Result rows for the comparison period when `compareFilter.compare` is true. */compare?: SpanTreeNode[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */@@ -35366,13 +35458,13 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative81 {+ export interface QueryResponseAlternative82 {questions: string[];/** Data warehouse sync warnings — see AnalyticsQueryResponseBase.warnings for semantics. */warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative82 {+ export interface QueryResponseAlternative83 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;hasMore?: boolean | null;@@ -35393,7 +35485,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative83 {+ export interface QueryResponseAlternative84 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;hasMore?: boolean | null;@@ -35414,7 +35506,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative84 {+ export interface QueryResponseAlternative85 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35432,7 +35524,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative85 {+ export interface QueryResponseAlternative86 {columns?: string[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -35454,7 +35546,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative87 {+ export interface QueryResponseAlternative88 {/** Timestamp of the newer trace */newerTimestamp?: string | null;/** ID of the newer trace (chronologically after current) */@@ -35469,7 +35561,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative88 {+ export interface QueryResponseAlternative89 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35487,7 +35579,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative89 {+ export interface QueryResponseAlternative90 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35505,7 +35597,31 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative90 {+ export interface QueryResponseAlternative91 {+ columns: unknown[];+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null;+ hasMore?: boolean | null;+ /** Generated HogQL query. */+ hogql: string;+ kind?: 'AccountsQuery';+ limit: number;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ offset: number;+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatus | null;+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponse | null;+ results: unknown[][];+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTiming[] | null;+ types: string[];+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */+ warnings?: DataWarehouseSyncWarning[] | null;+ }++ export interface QueryResponseAlternative92 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35523,7 +35639,7 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative91 {+ export interface QueryResponseAlternative93 {columns?: unknown[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -35546,9 +35662,9 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export type QueryResponseAlternative92ResultsItem = { [key: string]: unknown };+ export type QueryResponseAlternative94ResultsItem = { [key: string]: unknown };- export interface QueryResponseAlternative92 {+ export interface QueryResponseAlternative94 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35559,14 +35675,14 @@ export namespace Schemas {query_status?: QueryStatus | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: QueryResponseAlternative92ResultsItem[];+ results: QueryResponseAlternative94ResultsItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarning[] | null;}- export interface QueryResponseAlternative93 {+ export interface QueryResponseAlternative95 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -35584,18 +35700,18 @@ export namespace Schemas {warnings?: DataWarehouseSyncWarning[] | null;}- export type QueryResponseAlternative = { [key: string]: unknown } | QueryResponseAlternative1 | QueryResponseAlternative2 | QueryResponseAlternative3 | QueryResponseAlternative4 | QueryResponseAlternative5 | QueryResponseAlternative6 | QueryResponseAlternative7 | QueryResponseAlternative8 | QueryResponseAlternative9 | QueryResponseAlternative10 | QueryResponseAlternative11 | QueryResponseAlternative14 | QueryResponseAlternative15 | QueryResponseAlternative16 | QueryResponseAlternative17 | QueryResponseAlternative18 | QueryResponseAlternative19 | QueryResponseAlternative20 | QueryResponseAlternative21 | QueryResponseAlternative22 | QueryResponseAlternative23 | QueryResponseAlternative24 | QueryResponseAlternative25 | QueryResponseAlternative26 | QueryResponseAlternative27 | QueryResponseAlternative28 | QueryResponseAlternative29 | QueryResponseAlternative30 | QueryResponseAlternative31 | QueryResponseAlternative32 | QueryResponseAlternative33 | QueryResponseAlternative34 | QueryResponseAlternative35 | QueryResponseAlternative36 | QueryResponseAlternative37 | QueryResponseAlternative38 | unknown | QueryResponseAlternative39 | QueryResponseAlternative40 | QueryResponseAlternative41 | QueryResponseAlternative42 | QueryResponseAlternative43 | QueryResponseAlternative44 | QueryResponseAlternative45 | QueryResponseAlternative46 | QueryResponseAlternative47 | QueryResponseAlternative48 | QueryResponseAlternative49 | QueryResponseAlternative50 | QueryResponseAlternative51 | QueryResponseAlternative52 | QueryResponseAlternative53 | QueryResponseAlternative54 | QueryResponseAlternative55 | QueryResponseAlternative57 | QueryResponseAlternative58 | QueryResponseAlternative59 | QueryResponseAlternative60 | QueryResponseAlternative62 | QueryResponseAlternative63 | QueryResponseAlternative64 | QueryResponseAlternative65 | QueryResponseAlternative66 | QueryResponseAlternative67 | QueryResponseAlternative68 | QueryResponseAlternative69 | QueryResponseAlternative70 | QueryResponseAlternative72 | QueryResponseAlternative73 | QueryResponseAlternative74 | QueryResponseAlternative75 | QueryResponseAlternative76 | QueryResponseAlternative77 | QueryResponseAlternative78 | QueryResponseAlternative79 | QueryResponseAlternative80 | QueryResponseAlternative81 | QueryResponseAlternative82 | QueryResponseAlternative83 | QueryResponseAlternative84 | QueryResponseAlternative85 | QueryResponseAlternative87 | QueryResponseAlternative88 | QueryResponseAlternative89 | QueryResponseAlternative90 | QueryResponseAlternative91 | QueryResponseAlternative92 | QueryResponseAlternative93;+ export type QueryResponseAlternative = { [key: string]: unknown } | QueryResponseAlternative1 | QueryResponseAlternative2 | QueryResponseAlternative3 | QueryResponseAlternative4 | QueryResponseAlternative5 | QueryResponseAlternative6 | QueryResponseAlternative7 | QueryResponseAlternative8 | QueryResponseAlternative9 | QueryResponseAlternative10 | QueryResponseAlternative11 | QueryResponseAlternative14 | QueryResponseAlternative15 | QueryResponseAlternative16 | QueryResponseAlternative17 | QueryResponseAlternative18 | QueryResponseAlternative19 | QueryResponseAlternative20 | QueryResponseAlternative21 | QueryResponseAlternative22 | QueryResponseAlternative23 | QueryResponseAlternative24 | QueryResponseAlternative25 | QueryResponseAlternative26 | QueryResponseAlternative27 | QueryResponseAlternative28 | QueryResponseAlternative29 | QueryResponseAlternative30 | QueryResponseAlternative31 | QueryResponseAlternative32 | QueryResponseAlternative33 | QueryResponseAlternative34 | QueryResponseAlternative35 | QueryResponseAlternative36 | QueryResponseAlternative37 | QueryResponseAlternative38 | unknown | QueryResponseAlternative39 | QueryResponseAlternative40 | QueryResponseAlternative41 | QueryResponseAlternative42 | QueryResponseAlternative43 | QueryResponseAlternative44 | QueryResponseAlternative45 | QueryResponseAlternative46 | QueryResponseAlternative47 | QueryResponseAlternative48 | QueryResponseAlternative49 | QueryResponseAlternative50 | QueryResponseAlternative51 | QueryResponseAlternative52 | QueryResponseAlternative53 | QueryResponseAlternative54 | QueryResponseAlternative55 | QueryResponseAlternative57 | QueryResponseAlternative58 | QueryResponseAlternative59 | QueryResponseAlternative60 | QueryResponseAlternative62 | QueryResponseAlternative63 | QueryResponseAlternative64 | QueryResponseAlternative65 | QueryResponseAlternative66 | QueryResponseAlternative67 | QueryResponseAlternative68 | QueryResponseAlternative69 | QueryResponseAlternative70 | QueryResponseAlternative71 | QueryResponseAlternative73 | QueryResponseAlternative74 | QueryResponseAlternative75 | QueryResponseAlternative76 | QueryResponseAlternative77 | QueryResponseAlternative78 | QueryResponseAlternative79 | QueryResponseAlternative80 | QueryResponseAlternative81 | QueryResponseAlternative82 | QueryResponseAlternative83 | QueryResponseAlternative84 | QueryResponseAlternative85 | QueryResponseAlternative86 | QueryResponseAlternative88 | QueryResponseAlternative89 | QueryResponseAlternative90 | QueryResponseAlternative91 | QueryResponseAlternative92 | QueryResponseAlternative93 | QueryResponseAlternative94 | QueryResponseAlternative95;export interface QueryStatusResponse {query_status: QueryStatus;}export interface QueryUpgradeRequest {- query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | PropertyValuesQuery;+ query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | PropertyValuesQuery;}export interface QueryUpgradeResponse {- query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | PropertyValuesQuery;+ query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | RevenueExampleEventsQuery | RevenueExampleDataWarehouseTablesQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | RevenueAnalyticsGrossRevenueQuery | RevenueAnalyticsMetricsQuery | RevenueAnalyticsMRRQuery | RevenueAnalyticsOverviewQuery | RevenueAnalyticsTopCustomersQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | PropertyValuesQuery;}export interface QuotaResourceLimit {