Skip to content

: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.

feat(customer-analytics): switch accounts list to postgres (#79992)

Arthur Moreira de Deusa441d474f740
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 761a06fc0de4..7bba03533e40 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -277,6 +277,7 @@ export const FEATURE_FLAGS = {
CRM_ITERATION_ONE: 'crm-iteration-one', // owner: @arthurdedeus #team-customer-analytics
CUSTOMER_ANALYTICS: 'customer-analytics-roadmap', // owner: @arthurdedeus #team-customer-analytics
CUSTOMER_ANALYTICS_ACCOUNTS_HOGQL_CLEANUP: 'customer-analytics-accounts-hogql-cleanup', // owner: @arthurdedeus #team-customer-analytics, hides account columns that require custom HogQL or data warehouse joins
+ CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES: 'customer-analytics-accounts-postgres', // owner: @arthurdedeus #team-customer-analytics, runs supported Accounts list queries directly in Postgres
CUSTOMER_ANALYTICS_CSP: 'customer-analytics-csp', // owner: @arthurdedeus #team-customer-analytics, gates the Customer analytics > Accounts settings tab (account_group_type_index dropdown)
CUSTOMER_ANALYTICS_JOURNEYS: 'customer-analytics-journeys', // owner: @arthurdedeus #team-customer-analytics
CUSTOMER_PROFILE_CONFIG_BUTTON: 'customer-profile-config-button', // owner: @arthurdedeus #team-customer-analytics
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
index 9fa1570a5754..a7c8e5da7c36 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
@@ -382,6 +382,31 @@ describe('dataNodeLogic', () => {
})
})
+ it('can load next data for AccountsTableQuery', async () => {
+ logic = dataNodeLogic({
+ key: testUniqueKey,
+ query: setLatestVersionsOnQuery({ kind: NodeKind.AccountsTableQuery, columns: [], filters: [] }),
+ })
+ const results = [{ id: 'account-1' }, { id: 'account-2' }, { id: 'account-3' }]
+ mockedQuery.mockResolvedValueOnce({ results, hasMore: true })
+ logic.mount()
+ await expectLogic(logic)
+ .toMatchValues({ responseLoading: true, canLoadNextData: false, nextQuery: null, response: null })
+ .delay(0)
+ await expectLogic(logic).toMatchValues({
+ responseLoading: false,
+ canLoadNextData: true,
+ nextQuery: setLatestVersionsOnQuery({
+ kind: NodeKind.AccountsTableQuery,
+ columns: [],
+ filters: [],
+ limit: 100,
+ offset: 3,
+ }),
+ response: partial({ results }),
+ })
+ })
+
it('can autoload new data for EventsQuery', async () => {
const results = [
[
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
index 4fae5cc42e53..286ec5ca6e64 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
@@ -41,6 +41,8 @@ import {
DashboardFilter,
AccountsQuery,
AccountsQueryResponse,
+ AccountsTableQuery,
+ AccountsTableQueryResponse,
DataNode,
DataVisualizationNode,
ErrorTrackingQuery,
@@ -72,6 +74,7 @@ import {
} from '~/queries/schema/schema-general'
import {
isAccountsQuery,
+ isAccountsTableQuery,
isActorsQuery,
isErrorTrackingQuery,
isEventsQuery,
@@ -1098,6 +1101,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
isSessionsQuery(props.query) ||
isMarketingAnalyticsTableQuery(props.query) ||
isAccountsQuery(props.query) ||
+ isAccountsTableQuery(props.query) ||
isWebStatsTableQuery(props.query)
) {
const newResponse =
@@ -1123,6 +1127,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQueryResponse
| MarketingAnalyticsTableQueryResponse
| AccountsQueryResponse
+ | AccountsTableQueryResponse
| WebStatsTableQueryResponse
let results = [...(queryResponse?.results ?? []), ...(newResponse?.results ?? [])]
@@ -1508,6 +1513,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
isSessionsQuery(query) ||
isMarketingAnalyticsTableQuery(query) ||
isAccountsQuery(query) ||
+ isAccountsTableQuery(query) ||
isWebStatsTableQuery(query)) &&
!responseError &&
!dataLoading
@@ -1524,11 +1530,12 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQueryResponse
| MarketingAnalyticsTableQueryResponse
| AccountsQueryResponse
+ | AccountsTableQueryResponse
| WebStatsTableQueryResponse
)?.hasMore
) {
const sortKey =
- isTracesQuery(query) || isSessionQuery(query)
+ isTracesQuery(query) || isSessionQuery(query) || isAccountsTableQuery(query)
? null
: (query.orderBy?.[0] ?? 'timestamp DESC')
if (isEventsQuery(query) && sortKey === 'timestamp DESC') {
@@ -1566,6 +1573,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQueryResponse
| MarketingAnalyticsTableQueryResponse
| AccountsQueryResponse
+ | AccountsTableQueryResponse
| WebStatsTableQueryResponse
)?.results
return {
@@ -1585,6 +1593,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQuery
| MarketingAnalyticsTableQuery
| AccountsQuery
+ | AccountsTableQuery
| WebStatsTableQuery
}
}
diff --git a/frontend/src/queries/nodes/DataTable/queryFeatures.test.ts b/frontend/src/queries/nodes/DataTable/queryFeatures.test.ts
index 4c939467c3f3..dee624125c9d 100644
--- a/frontend/src/queries/nodes/DataTable/queryFeatures.test.ts
+++ b/frontend/src/queries/nodes/DataTable/queryFeatures.test.ts
@@ -1,4 +1,4 @@
-import { NodeKind } from '~/queries/schema/schema-general'
+import { AccountsTableQuery, NodeKind } from '~/queries/schema/schema-general'
import { QueryFeature, getQueryFeatures } from './queryFeatures'
@@ -32,6 +32,15 @@ describe('getQueryFeatures', () => {
})
})
+ describe('resultIsArrayOfArrays', () => {
+ it('uses positional rendering for translated Accounts table rows', () => {
+ const query: AccountsTableQuery = { kind: NodeKind.AccountsTableQuery, columns: [], filters: [] }
+ const features = getQueryFeatures(query)
+
+ expect(features.has(QueryFeature.resultIsArrayOfArrays)).toBe(true)
+ })
+ })
+
describe('testAccountFilters', () => {
// The persons list is a source-less ActorsQuery and must expose the toggle. An ActorsQuery
// with an insight source uses that source's own toggle instead, so it must not.
diff --git a/frontend/src/queries/nodes/DataTable/queryFeatures.ts b/frontend/src/queries/nodes/DataTable/queryFeatures.ts
index 1e2159b5f3a0..e78a8bc4590b 100644
--- a/frontend/src/queries/nodes/DataTable/queryFeatures.ts
+++ b/frontend/src/queries/nodes/DataTable/queryFeatures.ts
@@ -1,6 +1,7 @@
import { Node } from '~/queries/schema/schema-general'
import {
isAccountsQuery,
+ isAccountsTableQuery,
isActorsQuery,
isEndpointsUsageTableQuery,
isEventsQuery,
@@ -163,5 +164,10 @@ export function getQueryFeatures(query: Node): Set<QueryFeature> {
features.add(QueryFeature.selectAndOrderByColumns)
}
+ if (isAccountsTableQuery(query)) {
+ features.add(QueryFeature.resultIsArrayOfArrays)
+ features.add(QueryFeature.displayResponseError)
+ }
+
return features
}
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index e1a6380cf669..de1c427bd592 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -18188,6 +18188,84 @@
},
"required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],
"type": "object"
+ },
+ {
+ "additionalProperties": false,
+ "properties": {
+ "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": "AccountsTableQuery",
+ "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_compare_date_range": {
+ "$ref": "#/definitions/ResolvedDateRangeResponse",
+ "description": "The resolved previous/comparison period date range, when comparing against another period"
+ },
+ "resolved_date_range": {
+ "$ref": "#/definitions/ResolvedDateRangeResponse",
+ "description": "The date range used for the query"
+ },
+ "results": {
+ "items": {
+ "$ref": "#/definitions/AccountsTableRow"
+ },
+ "type": "array"
+ },
+ "timings": {
+ "description": "Measured timings for different parts of the query generation process",
+ "items": {
+ "$ref": "#/definitions/QueryTiming"
+ },
+ "type": "array"
+ },
+ "used_data_warehouse_sources": {
+ "description": "Connector-synced data warehouse sources referenced by this query, if any.",
+ "items": {
+ "$ref": "#/definitions/DataWarehouseSourceUsage"
+ },
+ "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. Also carries access control warnings when a system-table query filters out objects the user can't access.",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/DataWarehouseSyncWarning"
+ },
+ {
+ "$ref": "#/definitions/AccessControlFilterWarning"
+ }
+ ]
+ },
+ "type": "array"
+ }
+ },
+ "required": ["hasMore", "kind", "limit", "offset", "results"],
+ "type": "object"
}
]
},
@@ -18396,6 +18474,9 @@
},
{
"$ref": "#/definitions/AccountsQuery"
+ },
+ {
+ "$ref": "#/definitions/AccountsTableQuery"
}
],
"required": ["kind"],
@@ -42712,6 +42793,84 @@
"required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],
"type": "object"
},
+ {
+ "additionalProperties": false,
+ "properties": {
+ "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": "AccountsTableQuery",
+ "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_compare_date_range": {
+ "$ref": "#/definitions/ResolvedDateRangeResponse",
+ "description": "The resolved previous/comparison period date range, when comparing against another period"
+ },
+ "resolved_date_range": {
+ "$ref": "#/definitions/ResolvedDateRangeResponse",
+ "description": "The date range used for the query"
+ },
+ "results": {
+ "items": {
+ "$ref": "#/definitions/AccountsTableRow"
+ },
+ "type": "array"
+ },
+ "timings": {
+ "description": "Measured timings for different parts of the query generation process",
+ "items": {
+ "$ref": "#/definitions/QueryTiming"
+ },
+ "type": "array"
+ },
+ "used_data_warehouse_sources": {
+ "description": "Connector-synced data warehouse sources referenced by this query, if any.",
+ "items": {
+ "$ref": "#/definitions/DataWarehouseSourceUsage"
+ },
+ "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. Also carries access control warnings when a system-table query filters out objects the user can't access.",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/DataWarehouseSyncWarning"
+ },
+ {
+ "$ref": "#/definitions/AccessControlFilterWarning"
+ }
+ ]
+ },
+ "type": "array"
+ }
+ },
+ "required": ["hasMore", "kind", "limit", "offset", "results"],
+ "type": "object"
+ },
{
"additionalProperties": false,
"properties": {
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index ce4d3c90bb3b..c4bcbf237116 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -1147,6 +1147,7 @@ export type DataTableNodeSourceUnion =
| SessionQuery
| EndpointsUsageTableQuery
| AccountsQuery
+ | AccountsTableQuery
export type DataTableNodeSource = DataTableNodeSourceUnion
@@ -1181,6 +1182,7 @@ export interface DataTableNode
| SessionQuery
| EndpointsUsageTableQuery
| AccountsQuery
+ | AccountsTableQuery
)['response']
>
>,
diff --git a/frontend/src/queries/utils.ts b/frontend/src/queries/utils.ts
index 8a4fe2519875..2cc199e0dc2c 100644
--- a/frontend/src/queries/utils.ts
+++ b/frontend/src/queries/utils.ts
@@ -6,6 +6,7 @@ import { getAppContext } from 'lib/utils/getAppContext'
import { ProductAnalyticsInsightNodeKind } from '~/queries/nodes/InsightQuery/defaults'
import {
AccountsQuery,
+ AccountsTableQuery,
ActionsNode,
ActorsQuery,
AnyDataWarehouseNode,
@@ -1034,6 +1035,10 @@ export function isAccountsQuery(node?: Record<string, any> | null): node is Acco
return node?.kind === NodeKind.AccountsQuery
}
+export function isAccountsTableQuery(node?: Record<string, any> | null): node is AccountsTableQuery {
+ return node?.kind === NodeKind.AccountsTableQuery
+}
+
export const TRAILING_MATH_TYPES = new Set<MathType>([BaseMathType.WeeklyActiveUsers, BaseMathType.MonthlyActiveUsers])
/**
diff --git a/posthog/api/query.py b/posthog/api/query.py
index 3dd772843012..1abf54da7d15 100644
--- a/posthog/api/query.py
+++ b/posthog/api/query.py
@@ -172,6 +172,16 @@ _QUERY_KIND_SCOPES: dict[str, list[str]] = {
}
+def _required_scopes_for_query_payload(query: object) -> list[str] | None:
+ current_query = query
+ while isinstance(current_query, dict):
+ kind = current_query.get("kind")
+ if isinstance(kind, str) and kind in _QUERY_KIND_SCOPES:
+ return _QUERY_KIND_SCOPES[kind]
+ current_query = current_query.get("source")
+ return None
+
+
class QueryViewSet(QueryCoalescingMixin, TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet):
# NOTE: Do we need to override the scopes for the "create"
scope_object = "query"
@@ -185,8 +195,7 @@ class QueryViewSet(QueryCoalescingMixin, TeamAndOrgViewSetMixin, PydanticModelMi
if getattr(view, "action", None) != "create":
return None
query = request.data.get("query") if isinstance(request.data, dict) else None
- kind = query.get("kind") if isinstance(query, dict) else None
- return _QUERY_KIND_SCOPES.get(kind) if isinstance(kind, str) else None
+ return _required_scopes_for_query_payload(query)
def get_throttles(self):
if self.action == "draft_sql":
diff --git a/posthog/schema.py b/posthog/schema.py
index 14aefbe4a6e7..affb0f2041bc 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -2451,7 +2451,7 @@ class QueryResponseAlternative7(BaseModel):
stdout: str | None = None
-class QueryResponseAlternative76(BaseModel):
+class QueryResponseAlternative77(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -6318,7 +6318,7 @@ class QueryResponseAlternative28(BaseModel):
status: ExternalQueryStatus
-class QueryResponseAlternative83(BaseModel):
+class QueryResponseAlternative84(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -15813,6 +15813,57 @@ class Response22(BaseModel):
)
+class Response23(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ error: str | None = Field(
+ default=None,
+ description=(
+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."
+ ),
+ )
+ hasMore: bool
+ hogql: str | None = Field(default=None, description="Generated HogQL query.")
+ kind: Literal["AccountsTableQuery"] = "AccountsTableQuery"
+ 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_compare_date_range: ResolvedDateRangeResponse | None = Field(
+ default=None,
+ description=("The resolved previous/comparison period date range, when comparing against another period"),
+ )
+ resolved_date_range: ResolvedDateRangeResponse | None = Field(
+ default=None, description="The date range used for the query"
+ )
+ results: list[AccountsTableRow]
+ timings: list[QueryTiming] | None = Field(
+ default=None,
+ description=("Measured timings for different parts of the query generation process"),
+ )
+ used_data_warehouse_sources: list[DataWarehouseSourceUsage] | None = Field(
+ default=None,
+ description=("Connector-synced data warehouse sources referenced by this query, if any."),
+ )
+ warnings: list[DataWarehouseSyncWarning | AccessControlFilterWarning] | 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. Also carries access control"
+ " warnings when a system-table query filters out objects the user can't"
+ " access."
+ ),
+ )
+
+
class DataWarehouseNode(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -21116,6 +21167,57 @@ class QueryResponseAlternative57(BaseModel):
class QueryResponseAlternative58(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ error: str | None = Field(
+ default=None,
+ description=(
+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."
+ ),
+ )
+ hasMore: bool
+ hogql: str | None = Field(default=None, description="Generated HogQL query.")
+ kind: Literal["AccountsTableQuery"] = "AccountsTableQuery"
+ 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_compare_date_range: ResolvedDateRangeResponse | None = Field(
+ default=None,
+ description=("The resolved previous/comparison period date range, when comparing against another period"),
+ )
+ resolved_date_range: ResolvedDateRangeResponse | None = Field(
+ default=None, description="The date range used for the query"
+ )
+ results: list[AccountsTableRow]
+ timings: list[QueryTiming] | None = Field(
+ default=None,
+ description=("Measured timings for different parts of the query generation process"),
+ )
+ used_data_warehouse_sources: list[DataWarehouseSourceUsage] | None = Field(
+ default=None,
+ description=("Connector-synced data warehouse sources referenced by this query, if any."),
+ )
+ warnings: list[DataWarehouseSyncWarning | AccessControlFilterWarning] | 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. Also carries access control"
+ " warnings when a system-table query filters out objects the user can't"
+ " access."
+ ),
+ )
+
+
+class QueryResponseAlternative59(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21164,7 +21266,7 @@ class QueryResponseAlternative58(BaseModel):
)
-class QueryResponseAlternative59(BaseModel):
+class QueryResponseAlternative60(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21218,7 +21320,7 @@ class QueryResponseAlternative59(BaseModel):
)
-class QueryResponseAlternative60(BaseModel):
+class QueryResponseAlternative61(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21265,7 +21367,7 @@ class QueryResponseAlternative60(BaseModel):
)
-class QueryResponseAlternative61(BaseModel):
+class QueryResponseAlternative62(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21312,7 +21414,7 @@ class QueryResponseAlternative61(BaseModel):
)
-class QueryResponseAlternative62(BaseModel):
+class QueryResponseAlternative63(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21359,7 +21461,7 @@ class QueryResponseAlternative62(BaseModel):
)
-class QueryResponseAlternative63(BaseModel):
+class QueryResponseAlternative64(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21406,7 +21508,7 @@ class QueryResponseAlternative63(BaseModel):
)
-class QueryResponseAlternative65(BaseModel):
+class QueryResponseAlternative66(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21458,7 +21560,7 @@ class QueryResponseAlternative65(BaseModel):
)
-class QueryResponseAlternative67(BaseModel):
+class QueryResponseAlternative68(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21510,7 +21612,7 @@ class QueryResponseAlternative67(BaseModel):
)
-class QueryResponseAlternative68(BaseModel):
+class QueryResponseAlternative69(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21562,7 +21664,7 @@ class QueryResponseAlternative68(BaseModel):
)
-class QueryResponseAlternative69(BaseModel):
+class QueryResponseAlternative70(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21610,7 +21712,7 @@ class QueryResponseAlternative69(BaseModel):
)
-class QueryResponseAlternative70(BaseModel):
+class QueryResponseAlternative71(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21657,7 +21759,7 @@ class QueryResponseAlternative70(BaseModel):
)
-class QueryResponseAlternative71(BaseModel):
+class QueryResponseAlternative72(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21704,7 +21806,7 @@ class QueryResponseAlternative71(BaseModel):
)
-class QueryResponseAlternative72(BaseModel):
+class QueryResponseAlternative73(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21755,7 +21857,7 @@ class QueryResponseAlternative72(BaseModel):
)
-class QueryResponseAlternative73(BaseModel):
+class QueryResponseAlternative74(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21806,7 +21908,7 @@ class QueryResponseAlternative73(BaseModel):
)
-class QueryResponseAlternative74(BaseModel):
+class QueryResponseAlternative75(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21857,7 +21959,7 @@ class QueryResponseAlternative74(BaseModel):
)
-class QueryResponseAlternative75(BaseModel):
+class QueryResponseAlternative76(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21908,7 +22010,7 @@ class QueryResponseAlternative75(BaseModel):
)
-class QueryResponseAlternative77(BaseModel):
+class QueryResponseAlternative78(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -21958,7 +22060,7 @@ class QueryResponseAlternative77(BaseModel):
)
-class QueryResponseAlternative78(BaseModel):
+class QueryResponseAlternative79(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22008,7 +22110,7 @@ class QueryResponseAlternative78(BaseModel):
)
-class QueryResponseAlternative79(BaseModel):
+class QueryResponseAlternative80(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22055,7 +22157,7 @@ class QueryResponseAlternative79(BaseModel):
)
-class QueryResponseAlternative80(BaseModel):
+class QueryResponseAlternative81(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22106,7 +22208,7 @@ class QueryResponseAlternative80(BaseModel):
)
-class QueryResponseAlternative84(BaseModel):
+class QueryResponseAlternative85(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22153,7 +22255,7 @@ class QueryResponseAlternative84(BaseModel):
)
-class QueryResponseAlternative85(BaseModel):
+class QueryResponseAlternative86(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22200,7 +22302,7 @@ class QueryResponseAlternative85(BaseModel):
)
-class QueryResponseAlternative86(BaseModel):
+class QueryResponseAlternative87(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22257,7 +22359,7 @@ class QueryResponseAlternative86(BaseModel):
)
-class QueryResponseAlternative87(BaseModel):
+class QueryResponseAlternative88(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22308,7 +22410,7 @@ class QueryResponseAlternative87(BaseModel):
)
-class QueryResponseAlternative88(BaseModel):
+class QueryResponseAlternative89(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22355,7 +22457,7 @@ class QueryResponseAlternative88(BaseModel):
)
-class QueryResponseAlternative89(BaseModel):
+class QueryResponseAlternative90(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22407,7 +22509,7 @@ class QueryResponseAlternative89(BaseModel):
)
-class QueryResponseAlternative90(BaseModel):
+class QueryResponseAlternative91(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22454,7 +22556,7 @@ class QueryResponseAlternative90(BaseModel):
)
-class QueryResponseAlternative91(BaseModel):
+class QueryResponseAlternative92(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22501,7 +22603,7 @@ class QueryResponseAlternative91(BaseModel):
)
-class QueryResponseAlternative92(BaseModel):
+class QueryResponseAlternative93(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22548,7 +22650,7 @@ class QueryResponseAlternative92(BaseModel):
)
-class QueryResponseAlternative93(BaseModel):
+class QueryResponseAlternative94(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22595,7 +22697,7 @@ class QueryResponseAlternative93(BaseModel):
)
-class QueryResponseAlternative94(BaseModel):
+class QueryResponseAlternative95(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22642,7 +22744,7 @@ class QueryResponseAlternative94(BaseModel):
)
-class QueryResponseAlternative95(BaseModel):
+class QueryResponseAlternative96(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22689,7 +22791,7 @@ class QueryResponseAlternative95(BaseModel):
)
-class QueryResponseAlternative96(BaseModel):
+class QueryResponseAlternative97(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22736,7 +22838,7 @@ class QueryResponseAlternative96(BaseModel):
)
-class QueryResponseAlternative97(BaseModel):
+class QueryResponseAlternative98(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22786,7 +22888,7 @@ class QueryResponseAlternative97(BaseModel):
)
-class QueryResponseAlternative98(BaseModel):
+class QueryResponseAlternative99(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22833,7 +22935,7 @@ class QueryResponseAlternative98(BaseModel):
)
-class QueryResponseAlternative99(BaseModel):
+class QueryResponseAlternative100(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22880,7 +22982,7 @@ class QueryResponseAlternative99(BaseModel):
)
-class QueryResponseAlternative100(BaseModel):
+class QueryResponseAlternative101(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22927,7 +23029,7 @@ class QueryResponseAlternative100(BaseModel):
)
-class QueryResponseAlternative101(BaseModel):
+class QueryResponseAlternative102(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -22974,7 +23076,7 @@ class QueryResponseAlternative101(BaseModel):
)
-class QueryResponseAlternative102(BaseModel):
+class QueryResponseAlternative103(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -23021,7 +23123,7 @@ class QueryResponseAlternative102(BaseModel):
)
-class QueryResponseAlternative103(BaseModel):
+class QueryResponseAlternative104(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -23068,7 +23170,7 @@ class QueryResponseAlternative103(BaseModel):
)
-class QueryResponseAlternative104(BaseModel):
+class QueryResponseAlternative105(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -23115,7 +23217,7 @@ class QueryResponseAlternative104(BaseModel):
)
-class QueryResponseAlternative105(BaseModel):
+class QueryResponseAlternative106(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -23162,7 +23264,7 @@ class QueryResponseAlternative105(BaseModel):
)
-class QueryResponseAlternative106(BaseModel):
+class QueryResponseAlternative107(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -27490,7 +27592,7 @@ class PathsV2ActorsQuery(BaseModel):
version: float | None = Field(default=None, description="version of the node, used for schema migrations")
-class QueryResponseAlternative66(BaseModel):
+class QueryResponseAlternative67(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
@@ -28191,7 +28293,7 @@ class QueryResponseAlternative(
| QueryResponseAlternative61
| QueryResponseAlternative62
| QueryResponseAlternative63
- | QueryResponseAlternative65
+ | QueryResponseAlternative64
| QueryResponseAlternative66
| QueryResponseAlternative67
| QueryResponseAlternative68
@@ -28207,7 +28309,7 @@ class QueryResponseAlternative(
| QueryResponseAlternative78
| QueryResponseAlternative79
| QueryResponseAlternative80
- | QueryResponseAlternative83
+ | QueryResponseAlternative81
| QueryResponseAlternative84
| QueryResponseAlternative85
| QueryResponseAlternative86
@@ -28231,6 +28333,7 @@ class QueryResponseAlternative(
| QueryResponseAlternative104
| QueryResponseAlternative105
| QueryResponseAlternative106
+ | QueryResponseAlternative107
]
):
root: (
@@ -28297,7 +28400,7 @@ class QueryResponseAlternative(
| QueryResponseAlternative61
| QueryResponseAlternative62
| QueryResponseAlternative63
- | QueryResponseAlternative65
+ | QueryResponseAlternative64
| QueryResponseAlternative66
| QueryResponseAlternative67
| QueryResponseAlternative68
@@ -28313,7 +28416,7 @@ class QueryResponseAlternative(
| QueryResponseAlternative78
| QueryResponseAlternative79
| QueryResponseAlternative80
- | QueryResponseAlternative83
+ | QueryResponseAlternative81
| QueryResponseAlternative84
| QueryResponseAlternative85
| QueryResponseAlternative86
@@ -28337,6 +28440,7 @@ class QueryResponseAlternative(
| QueryResponseAlternative104
| QueryResponseAlternative105
| QueryResponseAlternative106
+ | QueryResponseAlternative107
)
@@ -29104,6 +29208,7 @@ class DataTableNode(BaseModel):
| Response19
| Response21
| Response22
+ | Response23
| None
) = None
showAbsoluteTime: bool | None = Field(
@@ -29193,6 +29298,7 @@ class DataTableNode(BaseModel):
| SessionQuery
| EndpointsUsageTableQuery
| AccountsQuery
+ | AccountsTableQuery
) = Field(..., description="Source of the events", discriminator="kind")
tags: QueryLogTags | None = None
version: float | None = Field(default=None, description="version of the node, used for schema migrations")
diff --git a/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py b/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
index daaefe4a41af..64ef289c41d1 100644
--- a/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
+++ b/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
@@ -696,25 +696,25 @@ class TestAccountsTableQueryAPI(APIBaseTest):
def test_query_endpoint_requires_account_scope_and_dispatches(self) -> None:
account = create_account(team_id=self.team.id, name="Acme")
endpoint = f"/api/projects/{self.team.id}/query/"
- payload = {
- "query": AccountsTableQuery(columns=[], filters=[]).model_dump(),
- "refresh": "force_blocking",
- }
-
- for incomplete_scopes in [["query:read"], ["account:read"]]:
- denied = self.client.post(
- endpoint,
- payload,
- format="json",
- headers={"authorization": f"Bearer {self._token(incomplete_scopes)}"},
- )
- assert denied.status_code == status.HTTP_403_FORBIDDEN
+ accounts_query = AccountsTableQuery(columns=[], filters=[]).model_dump()
+
+ for query in [accounts_query, {"kind": "DataTableNode", "source": accounts_query}]:
+ with self.subTest(query_kind=query["kind"]):
+ payload = {"query": query, "refresh": "force_blocking"}
+ for incomplete_scopes in [["query:read"], ["account:read"]]:
+ denied = self.client.post(
+ endpoint,
+ payload,
+ format="json",
+ headers={"authorization": f"Bearer {self._token(incomplete_scopes)}"},
+ )
+ assert denied.status_code == status.HTTP_403_FORBIDDEN
- allowed = self.client.post(
- endpoint,
- payload,
- format="json",
- headers={"authorization": f"Bearer {self._token(['query:read', 'account:read'])}"},
- )
- assert allowed.status_code == status.HTTP_200_OK, allowed.content
- assert [row["id"] for row in allowed.json()["results"]] == [str(account.id)]
+ allowed = self.client.post(
+ endpoint,
+ payload,
+ format="json",
+ headers={"authorization": f"Bearer {self._token(['query:read', 'account:read'])}"},
+ )
+ assert allowed.status_code == status.HTTP_200_OK, allowed.content
+ assert [row["id"] for row in allowed.json()["results"]] == [str(account.id)]
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index c3a28ff5fe94..802fadabf804 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -14,7 +14,7 @@ An **Account** is a customer organization. The list is a HogQL-backed table over
## Architecture
-The scene renders `AccountsTabContent`, which binds **two** `dataNodeLogic` instances (keys from `../../constants`): `ACCOUNTS_HOGQL_DATA_NODE_KEY` for the list rows (`accountsLogic.accountsQuerySource` — `hogqlQuery.source`, held at null until the relationship definitions settle so the list fetches exactly once with its final columns) and `ACCOUNTS_METRICS_DATA_NODE_KEY` for the overview-tile aggregations (`accountsLogic.metricsQuery`). They are deliberately split so the tiles' slower aggregations never block the list rows from rendering — each fires its own request and carries its own loading state. The table reads the list node; `accountsOverviewTilesLogic` reads the metrics node. Both queries share the same filters via `applyAccountFilters`, so they always describe the same set of accounts. Everything else reads from those bound data nodes or from the logics below.
+The scene renders `AccountsTabContent`, which binds **two** `dataNodeLogic` instances (keys from `../../constants`): `ACCOUNTS_HOGQL_DATA_NODE_KEY` for the list rows (`accountsLogic.accountsQuerySource`, held at null until the relationship definitions settle) and `ACCOUNTS_METRICS_DATA_NODE_KEY` for the overview-tile aggregations (`accountsLogic.metricsQuery`). The list source is the existing `AccountsQuery` by default. `CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES` switches supported state to `AccountsTableQuery`; unsupported columns and tile filters fall back to HogQL. Metrics remain on the HogQL runner. The requests stay split so slower aggregations never block list rows. The table reads the list node; `accountsOverviewTilesLogic` reads the metrics node.
```text
AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_HOGQL_DATA_NODE_KEY, accountsLogic.accountsQuerySource) [list rows]
@@ -42,7 +42,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_HOGQL_DATA_NODE_KEY, acc
| Logic | Owns |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `accountsLogic` | The hub. Search (debounced), tag / assigned-to/unassigned / custom-property filters, sort, inline role assignment, the `hogqlQuery` selector, shareable URL-hash view state, and `openAccount` (the Max entry point). `connect`s column-config, overview-tiles, and expansion logics. |
+| `accountsLogic` | The hub. Search (debounced), tag / assigned-to/unassigned / custom-property filters, sort, inline role assignment, HogQL and Postgres list-query selection, shareable URL-hash view state, and `openAccount` (the Max entry point). `accountsTableQueryPlan` translates live, saved-view, and URL-restored state into typed references; `tableRowsTransformer` adapts keyed Postgres rows for the existing table. `connect`s column-config, overview-tiles, and expansion logics. |
| `accountsViewsLogic` | Saved-views lifecycle (list/create/update/delete/select). Connects to `accountsLogic`, `accountsColumnConfigLogic`, and `accountsOverviewTilesLogic`; is the single owner of reading and writing the `ColumnConfiguration` rows for this area. |
| `accountsColumnConfigLogic` | Selected columns (`selectColumns` / `visibleColumnNames`), the column-picker groups built from the DB schema + data-warehouse joins, and the per-team saved column config (`columnConfigurations` API), and the custom-property definitions: it loads them, seeds `propertyDefinitionsModel` (so the filter UI resolves per-type operator sets), and exposes `customPropertyTaxonomicOptions` / `customPropertyDefinitionsById`. When `CUSTOMER_ANALYTICS_ACCOUNTS_HOGQL_CLEANUP` is enabled, the picker only offers Postgres-backed account fields, tags, notes, relationships, and custom properties. |
| `accountsExpansionLogic` | Which rows are expanded (`expandedAccountIds`) and the active tab per account (`activeTabByAccount`). Pure state — no DOM, no data fetching. |
@@ -59,7 +59,9 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_HOGQL_DATA_NODE_KEY, acc
## Data & query model
-`accountsLogic.hogqlQuery` builds a `DataTableNode` wrapping an `AccountsQuery` for the list rows (`select`, plus optional `search`, `tagNames`, `allRolesUnassigned`, `assignedToUserIds`, `filterExpression`, `orderBy`). The overview-tile `metrics` are **not** on this query — `accountsLogic.metricsQuery` is a separate metrics-only `AccountsQuery` (`metrics` set, no `select`; `null` when there are no tiles or while definitions are still loading) that the backend runner answers with its own aggregation query, so the tiles load without blocking the rows. Both queries share filters via `applyAccountFilters`. The backend runner (`accounts_query_runner`) returns **rows as arrays** aligned to `visibleColumnNames`, and tile aggregations in `metricsResults`. `assignedToUserIds` is the "assigned to" filter — a list of user ids the runner matches against accounts with an ACTIVE relationship assignment held by any of them (the single user-facing role filter; there are no separate per-role filters). The `allRolesUnassigned` flag (the "Unassigned only" option, surfaced inside the "Assigned to" picker — mutually exclusive with picking people via the cascade in `accountsLogic` listeners) restricts to accounts with no active relationship assignments at all. The "My accounts" checkbox is a client-side shortcut: `accountsLogic` resolves it to `[currentUserId]` (from `userLogic`) before the query is sent, so the backend only ever receives explicit ids and a shared URL resolves to the same accounts for every viewer. Its on/off state is mirrored into a shared `mineOnly` toggle on `customerAnalyticsSceneLogic` (localStorage-persisted, like `filterTestAccounts`) so the choice carries over to the Notes tab's own "My accounts" checkbox and back — `setAssignedToFilter` keeps `mineOnly` in step, and when the accounts URL carries no explicit `assignedTo` in its `#view` hash the filter falls back to `mineOnly` → `[currentUserId]`. (On the Notes tab "My accounts" filters notes to those on accounts assigned to you, via the `assigned_to` param on the account-notes endpoint; "My notes" there is the separate created-by shortcut and is not shared.) Two cell shapes matter:
+`accountsLogic.hogqlQuery` builds a `DataTableNode` wrapping the existing `AccountsQuery`. `accountsTableQueryPlan` translates the same selected columns, filters, custom-property display windows, and server-side sort into a typed `AccountsTableQuery`. When the Postgres flag is enabled and translation is complete, `accountsQuerySource` runs that query instead. The translator reads the live reducers after saved-view or URL restoration, so storage stays backward compatible. A tile filter or unsupported legacy expression returns no plan and keeps the list on HogQL. `tableRowsTransformer` converts keyed `AccountsTableRow`s into arrays aligned to `visibleColumnNames`, preserving the current table and cell components during rollout.
+
+The overview-tile `metrics` remain a separate metrics-only `AccountsQuery` (`metrics` set, no `select`; `null` when there are no tiles or while definitions are still loading). The "My accounts" checkbox remains a client-side shortcut that resolves to the current user's explicit ID before either list query is built, so shared URLs remain viewer-independent. Two cell shapes matter:
- **`name` column** (mandatory, `ACCOUNTS_NAME_COLUMN`) — emitted as `tuple(name, external_id, id)`, read as `{ name, external_id, id }`. This is the row's identity: `id` (the account PK) drives expansion/scroll/role updates; `external_id` is the copy-able group key. `getNameCell()` in `AccountsHogQLTable.tsx` is the canonical accessor; never assume a column index. In `NameCell` the name renders as the prominent (`font-semibold`) primary label: a plain click opens the account details inline (toggles the row's expansion via `accountsExpansionLogic`, firing `AccountOpened` on open), while the `<Link>` href points at `urls.customerAnalyticsAccount(id)` so cmd/ctrl-click opens the account's deep-link page in a new tab. The `external_id` sits beneath it as de-emphasized (`text-xs text-muted`) copy-to-clipboard text.
- **relationship columns** — backed by the ``accounts.relationships.values.`<definition_id>` `` lazy join, emitted as the **array of active assignee user ids** (`[]` when unassigned). The legacy names `csm`/`account_executive`/`account_owner` remain the STORED column names (in defaults, saved views, and URL state) and are translated into the lazy-join expression at query-build time by `translateSelectColumns` in `accountsColumnConfigLogic`, matched by seeded definition name (`LEGACY_ROLE_COLUMNS`); a legacy column with no matching definition is dropped from the query. Other definitions are pickable from the "Relationships" column group with opaque `rel_<id>` aliases, resolved back via `aliasToRelationshipDefinition`. Cells render `RelationshipCell`: single-holder definitions get an editable `MemberSelect` (writes via the relationships assign/end endpoints — assign auto-ends the previous holder server-side); multi-holder definitions render read-only. User ids resolve to members via `membersLogic` (loaded up front in `accountsLogic.afterMount`). Sorting uses the alias directly (arrays of ids — deterministic but not email order).
@@ -221,7 +223,7 @@ The tool is registered for the page regardless of agent mode. The Customer analy
- `products/customer_analytics/backend/models` — the `Account` model (`external_id` = group key).
- `products/customer_analytics/backend/hogql_queries/accounts_query_runner.py` — the current Accounts page query runner, which builds positional list rows through HogQL.
-- `products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py` — the typed Postgres-only `AccountsTableQuery` runner. It returns keyed rows, applies typed list filters and server-side sorting, and is not wired into the page yet.
+- `products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py` — the typed Postgres-only `AccountsTableQuery` runner. It returns keyed rows and applies typed list filters and server-side sorting. The Accounts page selects it behind `CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES` when runtime translation succeeds.
- `products/customer_analytics/backend/max_tools/` — `OpenAccountTool` and other account Max tools.
- `ee/hogai/core/agent_modes/presets/customer_analytics.py` — the Customer analytics agent mode (gated by the `customer-analytics-csp` flag).
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx
index ff50a8a50582..98fd467ee5b5 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx
@@ -615,7 +615,7 @@ function AccountsHogQLSkeleton(): JSX.Element {
}
export function AccountsHogQLTable(): JSX.Element {
- const { hogqlQuery, accountsQuerySource, sortedRowsTransformer } = useValues(accountsLogic)
+ const { accountsDataTableQuery, accountsQuerySource, tableRowsTransformer } = useValues(accountsLogic)
const { responseLoading, response } = useValues(dataNodeLogic)
const contextColumns = useContextColumns()
const expandable = useExpandable()
@@ -628,14 +628,14 @@ export function AccountsHogQLTable(): JSX.Element {
<div className="@container">
<DataTable
uniqueKey="customer-analytics-accounts-hogql"
- query={hogqlQuery}
+ query={accountsDataTableQuery}
setQuery={() => {
// Filters are owned by accountsLogic; column/sort changes from the DataTable are ignored on purpose.
}}
context={{
columns: contextColumns,
expandable,
- dataTableRowsTransformer: sortedRowsTransformer,
+ dataTableRowsTransformer: tableRowsTransformer,
dataNodeLogicKey: ACCOUNTS_HOGQL_DATA_NODE_KEY,
emptyStateHeading: 'There are no matching accounts for this query',
emptyStateDetail: 'Try adjusting the filters or refreshing',
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
index 94c5b621a294..2236ca20f7fa 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
@@ -8,7 +8,8 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
-import type { AccountsQuery } from '~/queries/schema/schema-general'
+import type { DataTableRow } from '~/queries/nodes/DataTable/dataTableLogic'
+import type { AccountsQuery, AccountsTableQuery } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
import type { UserBasicType, UserType } from '~/types'
@@ -68,10 +69,14 @@ const mockRelationshipsEnd = accountsRelationshipsEndCreate as jest.MockedFuncti
const mockRelationshipsList = accountsRelationshipsList as jest.MockedFunction<typeof accountsRelationshipsList>
const mockPartialUpdate = accountsPartialUpdate as jest.MockedFunction<typeof accountsPartialUpdate>
+const CSM_DEFINITION_ID = '11111111-2222-3333-4444-555555555555'
+const AE_DEFINITION_ID = '66666666-7777-8888-9999-aaaaaaaaaaaa'
+const OWNER_DEFINITION_ID = 'bbbbbbbb-cccc-dddd-eeee-ffffffffffff'
+
const DEFINITIONS: AccountRelationshipDefinitionApi[] = [
- { id: 'def-csm', name: 'CSM', description: null, is_single_holder: true },
- { id: 'def-ae', name: 'Account executive', description: null, is_single_holder: true },
- { id: 'def-owner', name: 'Account owner', description: null, is_single_holder: true },
+ { id: CSM_DEFINITION_ID, name: 'CSM', description: null, is_single_holder: true },
+ { id: AE_DEFINITION_ID, name: 'Account executive', description: null, is_single_holder: true },
+ { id: OWNER_DEFINITION_ID, name: 'Account owner', description: null, is_single_holder: true },
]
const buildRelationship = (overrides: Partial<AccountRelationshipApi> = {}): AccountRelationshipApi => ({
@@ -143,6 +148,111 @@ describe('accountsLogic', () => {
expect(config.values.accountsColumnGroups.map((group) => group.key)).not.toContain('sql_expression')
})
+ it('switches supported list queries to Postgres behind the execution flag', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+
+ const source = logic.values.accountsQuerySource as AccountsTableQuery
+ expect(source.kind).toBe('AccountsTableQuery')
+ expect(source.columns).toEqual([
+ { kind: 'account_field', field: 'name' },
+ { kind: 'tags' },
+ { kind: 'note_count' },
+ { kind: 'relationship', definitionId: CSM_DEFINITION_ID },
+ { kind: 'relationship', definitionId: AE_DEFINITION_ID },
+ { kind: 'relationship', definitionId: OWNER_DEFINITION_ID },
+ ])
+ expect(logic.values.metricsQuery?.kind).toBe('AccountsQuery')
+ })
+
+ it('keeps the DataTable data node on the active Postgres source for refreshes', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+
+ expect(logic.values.accountsDataTableQuery.source.kind).toBe('AccountsTableQuery')
+ expect(logic.values.accountsDataTableQuery.columns).toEqual(logic.values.visibleColumnNames)
+ })
+
+ it('keeps the previous positional response stable while switching runners', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+ const previousRows = [
+ { result: [{ id: 'account-id', name: 'Acme', external_id: 'acme' }, [], 0, [], [], []] },
+ ] as DataTableRow[]
+
+ expect(logic.values.tableRowsTransformer?.(previousRows)).toEqual(previousRows)
+ })
+
+ it('keeps retained Postgres rows translated while a tile filter switches the runner to HogQL', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+ const keyedRows = [
+ {
+ result: {
+ id: 'account-id',
+ name: 'Acme',
+ externalId: 'acme',
+ accountFields: { name: 'Acme' },
+ tags: ['enterprise'],
+ noteCount: 2,
+ relationships: Object.fromEntries(DEFINITIONS.map(({ id }) => [id, []])),
+ customProperties: {},
+ customPropertyHistory: {},
+ },
+ },
+ ] as DataTableRow[]
+
+ logic.actions.setTileFilter({ tileId: 'tile', expression: 'count() > 1' })
+
+ expect(logic.values.accountsQuerySource?.kind).toBe('AccountsQuery')
+ expect(logic.values.tableRowsTransformer?.(keyedRows)[0].result).toEqual([
+ { id: 'account-id', name: 'Acme', external_id: 'acme' },
+ ['enterprise'],
+ 2,
+ [],
+ [],
+ [],
+ ])
+ })
+
+ it('hides incompatible retained Postgres rows while an unsupported column switches to HogQL', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+ const keyedRows = [
+ {
+ result: {
+ id: 'account-id',
+ name: 'Acme',
+ accountFields: { name: 'Acme' },
+ relationships: {},
+ customProperties: {},
+ customPropertyHistory: {},
+ },
+ },
+ ] as DataTableRow[]
+
+ accountsColumnConfigLogic
+ .findMounted()!
+ .actions.setSelectColumns([...logic.values.selectColumns, 'arbitrary_hogql()'])
+
+ expect(logic.values.accountsQuerySource?.kind).toBe('AccountsQuery')
+ expect(logic.values.tableRowsTransformer?.(keyedRows)).toEqual([])
+ })
+
+ it('keeps unsupported list state on the HogQL runner', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+ logic.actions.setTileFilter({ tileId: 'tile', expression: 'count() > 1' })
+
+ expect(logic.values.accountsQuerySource?.kind).toBe('AccountsQuery')
+ })
+
it('setTagsFilter updates the reducer', () => {
logic.actions.setTagsFilter(['enterprise'])
expect(logic.values.tagsFilter).toEqual(['enterprise'])
@@ -481,9 +591,9 @@ describe('accountsLogic', () => {
ACCOUNTS_NAME_COLUMN,
'accounts.tags.names AS tag_names',
'accounts.notebooks.count AS notebook_count',
- 'accounts.relationships.values.`def-csm` AS csm',
- 'accounts.relationships.values.`def-ae` AS account_executive',
- 'accounts.relationships.values.`def-owner` AS account_owner',
+ `accounts.relationships.values.\`${CSM_DEFINITION_ID}\` AS csm`,
+ `accounts.relationships.values.\`${AE_DEFINITION_ID}\` AS account_executive`,
+ `accounts.relationships.values.\`${OWNER_DEFINITION_ID}\` AS account_owner`,
])
})
@@ -597,6 +707,37 @@ describe('accountsLogic', () => {
expect(logic.values.assignedToFilter).toEqual([7])
})
+ it('translates restored URL state into the Postgres query', async () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+ router.actions.push(
+ urls.customerAnalyticsAccounts(),
+ {},
+ {
+ view: {
+ search: 'acme',
+ tags: ['enterprise'],
+ assignedTo: [7],
+ columns: [ACCOUNTS_NAME_COLUMN, 'csm'],
+ },
+ }
+ )
+ await expectLogic(logic).toFinishAllListeners()
+
+ const source = logic.values.accountsQuerySource as AccountsTableQuery
+ expect(source.kind).toBe('AccountsTableQuery')
+ expect(source.columns).toEqual([
+ { kind: 'account_field', field: 'name' },
+ { kind: 'relationship', definitionId: CSM_DEFINITION_ID },
+ ])
+ expect(source.filters).toEqual([
+ { kind: 'search', query: 'acme' },
+ { kind: 'tags', tagNames: ['enterprise'] },
+ { kind: 'assigned_to', userIds: [7] },
+ ])
+ })
+
it('restores columns from the view hash param', async () => {
router.actions.push(
urls.customerAnalyticsAccounts(),
@@ -700,7 +841,7 @@ describe('accountsLogic', () => {
await expectLogic(logic).toFinishAllListeners()
expect(mockRelationshipsCreate).toHaveBeenCalledWith(String(MOCK_DEFAULT_TEAM.id), 'acc-1', {
- definition: 'def-csm',
+ definition: CSM_DEFINITION_ID,
user: user.id,
})
expect(logic.values.relationshipOverrides[savingRoleKey('acc-1', 'csm')]).toEqual([user.id])
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
index d670da8330e5..2cf338927582 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
@@ -2,7 +2,9 @@ import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, redu
import { actionToUrl, router, urlToAction } from 'kea-router'
import posthog from 'posthog-js'
+import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { featureFlagLogic, type FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { isUUIDLike } from 'lib/utils/guards'
import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
import { objectsEqual } from 'lib/utils/objects'
@@ -14,7 +16,14 @@ import { userLogic } from 'scenes/userLogic'
import { tagsModel } from '~/models/tagsModel'
import { type DataNodeLogicProps, dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import type { DataTableRow } from '~/queries/nodes/DataTable/dataTableLogic'
-import { AccountsQuery, DataNode, DataTableNode, NodeKind, RefreshType } from '~/queries/schema/schema-general'
+import {
+ AccountsQuery,
+ AccountsTableQuery,
+ DataNode,
+ DataTableNode,
+ NodeKind,
+ RefreshType,
+} from '~/queries/schema/schema-general'
import type { AccountCustomPropertyFilter, UserBasicType } from '~/types'
import {
@@ -44,6 +53,13 @@ import {
} from './accountsExpansionLogic'
import { accountsOverviewTilesLogic, TileFilter } from './accountsOverviewTilesLogic'
import { sortAccountRows } from './accountsSort'
+import {
+ AccountsTableQueryPlan,
+ BuildAccountsTableQueryPlanInput,
+ accountsTableRowsToLegacyRows,
+ buildAccountsTableQueryPlan,
+ isAccountsTableRow,
+} from './accountsTableQuery'
import { normalizeRoleFilter } from './accountsViewState'
import { AccountsEvents } from './constants'
@@ -199,10 +215,15 @@ export interface accountsLogicValues {
tileFilter: TileFilter | null // accountsOverviewTilesLogic
mineOnly: boolean // customerAnalyticsSceneLogic
listHasMoreData: boolean // dataNodeLogic
+ featureFlags: FeatureFlagsSet // featureFlagLogic
currentTeamId: number | null // teamLogic
user: UserType | null // userLogic
accountIdFilter: string | null
- accountsQuerySource: AccountsQuery | null
+ accountsDataTableQuery: DataTableNode
+ accountsQuerySource: AccountsQuery | AccountsTableQuery | null
+ accountsTableQueryPlan: AccountsTableQueryPlan | null
+ accountsTableQueryPlanInput: BuildAccountsTableQueryPlanInput
+ accountsTableResponsePlan: AccountsTableQueryPlan | null
activeFilterCount: number
allRolesUnassigned: boolean
assignedToCurrentUser: boolean
@@ -215,6 +236,7 @@ export interface accountsLogicValues {
isTagsSaving: (accountId: string) => boolean
listPaginated: boolean
metricsQuery: AccountsQuery | null
+ postgresAccountsEnabled: boolean
relationshipOverrides: Record<string, number[]>
savingRoles: Record<string, true>
savingTags: Record<string, true>
@@ -222,6 +244,7 @@ export interface accountsLogicValues {
searchQuery: string
sortOrder: AccountSortOrder
sortedRowsTransformer: ((rows: DataTableRow[]) => DataTableRow[]) | undefined
+ tableRowsTransformer: ((rows: DataTableRow[]) => DataTableRow[]) | undefined
tagOverrides: Record<string, string[]>
tagsFilter: string[]
viewUrlState: AccountsViewUrlState
@@ -434,6 +457,28 @@ export interface accountsLogicMeta {
sortOrder: AccountSortOrder,
visibleColumnNames: string[]
) => ((rows: DataTableRow[]) => DataTableRow[]) | undefined
+ postgresAccountsEnabled: (featureFlags: FeatureFlagsSet) => boolean
+ accountsTableQueryPlanInput: (
+ querySelectColumns: string[],
+ visibleColumnNames: string[],
+ searchQuery: string,
+ tagsFilter: string[],
+ allRolesUnassigned: boolean,
+ assignedToFilter: RoleFilterValue,
+ accountIdFilter: string | null,
+ tileFilter: TileFilter | null,
+ customPropertyFilters: AccountCustomPropertyFilter[],
+ customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
+ columnDisplay: AccountColumnDisplayState,
+ sortOrder: AccountSortOrder,
+ canSortClientSide: boolean
+ ) => BuildAccountsTableQueryPlanInput
+ accountsTableQueryPlan: (
+ accountsTableQueryPlanInput: BuildAccountsTableQueryPlanInput
+ ) => AccountsTableQueryPlan | null
+ accountsTableResponsePlan: (
+ accountsTableQueryPlanInput: BuildAccountsTableQueryPlanInput
+ ) => AccountsTableQueryPlan | null
hogqlQuery: (
searchQuery: string,
tagsFilter: string[],
@@ -449,7 +494,21 @@ export interface accountsLogicMeta {
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
aliasToDefinition: Record<string, CustomPropertyDefinitionApi>
) => DataTableNode
- accountsQuerySource: (hogqlQuery: DataTableNode, relationshipDefinitionsLoaded: boolean) => AccountsQuery | null
+ accountsQuerySource: (
+ hogqlQuery: DataTableNode,
+ accountsTableQueryPlan: AccountsTableQueryPlan | null,
+ postgresAccountsEnabled: boolean,
+ relationshipDefinitionsLoaded: boolean
+ ) => AccountsQuery | AccountsTableQuery | null
+ accountsDataTableQuery: (
+ hogqlQuery: DataTableNode,
+ accountsQuerySource: AccountsQuery | AccountsTableQuery | null,
+ visibleColumnNames: string[]
+ ) => DataTableNode
+ tableRowsTransformer: (
+ accountsTableResponsePlan: AccountsTableQueryPlan | null,
+ sortedRowsTransformer: ((rows: DataTableRow[]) => DataTableRow[]) | undefined
+ ) => ((rows: DataTableRow[]) => DataTableRow[]) | undefined
metricsQuery: (
overviewMetrics: string[],
searchQuery: string,
@@ -480,6 +539,8 @@ export const accountsLogic = kea<accountsLogicType>([
['currentTeamId'],
userLogic,
['user'],
+ featureFlagLogic,
+ ['featureFlags'],
accountsColumnConfigLogic,
[
'selectColumns',
@@ -796,6 +857,67 @@ export const accountsLogic = kea<accountsLogicType>([
? (rows: DataTableRow[]): DataTableRow[] => sortAccountRows(rows, sortOrder, visibleColumnNames)
: undefined,
],
+ postgresAccountsEnabled: [
+ (s) => [s.featureFlags],
+ (featureFlags: FeatureFlagsSet): boolean =>
+ !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES],
+ ],
+ accountsTableQueryPlanInput: [
+ (s) => [
+ s.querySelectColumns,
+ s.visibleColumnNames,
+ s.searchQuery,
+ s.tagsFilter,
+ s.allRolesUnassigned,
+ s.assignedToFilter,
+ s.accountIdFilter,
+ s.tileFilter,
+ s.customPropertyFilters,
+ s.customPropertyDefinitionsById,
+ s.columnDisplay,
+ s.sortOrder,
+ s.canSortClientSide,
+ ],
+ (
+ querySelectColumns: string[],
+ visibleColumnNames: string[],
+ searchQuery: string,
+ tagsFilter: string[],
+ allRolesUnassigned: boolean,
+ assignedToFilter: RoleFilterValue,
+ accountIdFilter: string | null,
+ tileFilter: TileFilter | null,
+ customPropertyFilters: AccountCustomPropertyFilter[],
+ customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
+ columnDisplay: AccountColumnDisplayState,
+ sortOrder: AccountSortOrder,
+ canSortClientSide: boolean
+ ): BuildAccountsTableQueryPlanInput => ({
+ querySelectColumns,
+ visibleColumnNames,
+ searchQuery,
+ tagsFilter,
+ allRolesUnassigned,
+ assignedToFilter,
+ accountIdFilter,
+ tileFilter,
+ customPropertyFilters,
+ customPropertyDefinitionsById,
+ columnDisplay,
+ sortOrder,
+ canSortClientSide,
+ }),
+ ],
+ accountsTableQueryPlan: [
+ (s) => [s.accountsTableQueryPlanInput],
+ (input: BuildAccountsTableQueryPlanInput): AccountsTableQueryPlan | null =>
+ buildAccountsTableQueryPlan(input),
+ ],
+ accountsTableResponsePlan: [
+ (s) => [s.accountsTableQueryPlanInput],
+ (input: BuildAccountsTableQueryPlanInput): AccountsTableQueryPlan | null =>
+ buildAccountsTableQueryPlan({ ...input, tileFilter: null }),
+ ],
hogqlQuery: [
(s) => [
s.searchQuery,
@@ -863,9 +985,54 @@ export const accountsLogic = kea<accountsLogicType>([
// definitions settle, so the list fetches once with its final columns
// instead of fetching base columns and refetching after the upgrade.
accountsQuerySource: [
- (s) => [s.hogqlQuery, s.relationshipDefinitionsLoaded],
- (hogqlQuery: DataTableNode, relationshipDefinitionsLoaded: boolean): AccountsQuery | null =>
- relationshipDefinitionsLoaded ? (hogqlQuery.source as AccountsQuery) : null,
+ (s) => [s.hogqlQuery, s.accountsTableQueryPlan, s.postgresAccountsEnabled, s.relationshipDefinitionsLoaded],
+ (
+ hogqlQuery: DataTableNode,
+ accountsTableQueryPlan: AccountsTableQueryPlan | null,
+ postgresAccountsEnabled: boolean,
+ relationshipDefinitionsLoaded: boolean
+ ): AccountsQuery | AccountsTableQuery | null => {
+ if (!relationshipDefinitionsLoaded) {
+ return null
+ }
+ return postgresAccountsEnabled && accountsTableQueryPlan
+ ? accountsTableQueryPlan.query
+ : (hogqlQuery.source as AccountsQuery)
+ },
+ ],
+ accountsDataTableQuery: [
+ (s) => [s.hogqlQuery, s.accountsQuerySource, s.visibleColumnNames],
+ (
+ hogqlQuery: DataTableNode,
+ accountsQuerySource: AccountsQuery | AccountsTableQuery | null,
+ visibleColumnNames: string[]
+ ): DataTableNode => ({
+ ...hogqlQuery,
+ columns: visibleColumnNames,
+ source: accountsQuerySource ?? hogqlQuery.source,
+ }),
+ ],
+ tableRowsTransformer: [
+ (s) => [s.accountsTableResponsePlan, s.sortedRowsTransformer],
+ (
+ accountsTableResponsePlan: AccountsTableQueryPlan | null,
+ sortedRowsTransformer: ((rows: DataTableRow[]) => DataTableRow[]) | undefined
+ ): ((rows: DataTableRow[]) => DataTableRow[]) | undefined =>
+ (rows: DataTableRow[]): DataTableRow[] => {
+ const rowResults = rows.map((row) => row.result)
+ if (!rowResults.some(isAccountsTableRow)) {
+ return sortedRowsTransformer ? sortedRowsTransformer(rows) : rows
+ }
+ if (!accountsTableResponsePlan || !rowResults.every(isAccountsTableRow)) {
+ return []
+ }
+ const translatedResults = accountsTableRowsToLegacyRows(rowResults, accountsTableResponsePlan)
+ const translatedRows = rows.map((row, index) => ({
+ ...row,
+ result: translatedResults[index],
+ }))
+ return sortedRowsTransformer ? sortedRowsTransformer(translatedRows) : translatedRows
+ },
],
// The overview-tile aggregations run as their own metrics-only query (no
// `select`), keyed to ACCOUNTS_METRICS_DATA_NODE_KEY, so they load
@@ -1116,6 +1283,9 @@ export const accountsLogic = kea<accountsLogicType>([
const isVisible =
nameIndex >= 0 &&
rows.some((row) => {
+ if (row && typeof row === 'object' && !Array.isArray(row)) {
+ return (row as { id?: string }).id === accountId
+ }
const cell = Array.isArray(row) ? (row as unknown[])[nameIndex] : undefined
return !!cell && typeof cell === 'object' && (cell as { id?: string }).id === accountId
})
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
new file mode 100644
index 000000000000..04493f811bef
--- /dev/null
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
@@ -0,0 +1,220 @@
+import {
+ AccountsTableAccountField,
+ AccountsTableCustomPropertyOperator,
+ AccountsTableSortDirection,
+ NodeKind,
+} from '~/queries/schema/schema-general'
+import { AccountCustomPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
+
+import type { CustomPropertyDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+
+import {
+ AccountsTableQueryPlan,
+ BuildAccountsTableQueryPlanInput,
+ accountsTableRowsToLegacyRows,
+ buildAccountsTableQueryPlan,
+} from './accountsTableQuery'
+
+const RELATIONSHIP_ID = '11111111-2222-3333-4444-555555555555'
+const CUSTOM_PROPERTY_ID = '66666666-7777-8888-9999-aaaaaaaaaaaa'
+
+const definition = {
+ id: CUSTOM_PROPERTY_ID,
+ name: 'MRR',
+ display_type: 'currency',
+} as CustomPropertyDefinitionApi
+
+function customFilter(overrides: Partial<AccountCustomPropertyFilter> = {}): AccountCustomPropertyFilter {
+ return {
+ type: PropertyFilterType.AccountCustomProperty,
+ key: CUSTOM_PROPERTY_ID,
+ operator: PropertyOperator.GreaterThan,
+ value: 10,
+ ...overrides,
+ }
+}
+
+function queryInput(overrides: Partial<BuildAccountsTableQueryPlanInput> = {}): BuildAccountsTableQueryPlanInput {
+ return {
+ querySelectColumns: [
+ 'name',
+ 'accounts.tags.names AS tag_names',
+ 'accounts.notebooks.count AS notebook_count',
+ `accounts.relationships.values.\`${RELATIONSHIP_ID}\` AS csm`,
+ ],
+ visibleColumnNames: ['name', 'tag_names', 'notebook_count', 'csm'],
+ searchQuery: '',
+ tagsFilter: [],
+ allRolesUnassigned: false,
+ assignedToFilter: [],
+ accountIdFilter: null,
+ tileFilter: null,
+ customPropertyFilters: [],
+ customPropertyDefinitionsById: { [CUSTOM_PROPERTY_ID]: definition },
+ columnDisplay: {},
+ sortOrder: null,
+ canSortClientSide: true,
+ ...overrides,
+ }
+}
+
+describe('accountsTableQuery', () => {
+ it('translates supported columns, filters, and server-side sorting', () => {
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ searchQuery: ' acme ',
+ tagsFilter: ['enterprise'],
+ assignedToFilter: [7, 9],
+ customPropertyFilters: [customFilter()],
+ sortOrder: { column: 'csm', direction: 'desc' },
+ canSortClientSide: false,
+ })
+ )
+
+ expect(plan?.query).toMatchObject({
+ kind: NodeKind.AccountsTableQuery,
+ columns: [
+ { kind: 'account_field', field: AccountsTableAccountField.Name },
+ { kind: 'tags' },
+ { kind: 'note_count' },
+ { kind: 'relationship', definitionId: RELATIONSHIP_ID },
+ ],
+ filters: [
+ { kind: 'search', query: 'acme' },
+ { kind: 'tags', tagNames: ['enterprise'] },
+ { kind: 'assigned_to', userIds: [7, 9] },
+ {
+ kind: 'custom_property',
+ definitionId: CUSTOM_PROPERTY_ID,
+ operator: AccountsTableCustomPropertyOperator.GreaterThan,
+ values: [10],
+ },
+ ],
+ sort: {
+ column: { kind: 'relationship', definitionId: RELATIONSHIP_ID },
+ direction: AccountsTableSortDirection.Descending,
+ },
+ })
+ })
+
+ it('translates saved custom-property history display configuration', () => {
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ querySelectColumns: [
+ 'name',
+ `accounts.custom_properties_history.values.\`${CUSTOM_PROPERTY_ID}\` AS cp_value`,
+ ],
+ visibleColumnNames: ['name', 'cp_value'],
+ columnDisplay: { [CUSTOM_PROPERTY_ID]: { mode: 'sparkline', window_days: 30 } },
+ sortOrder: { column: 'cp_value', direction: 'asc' },
+ canSortClientSide: false,
+ })
+ )
+
+ expect(plan?.query.columns[1]).toEqual({
+ kind: 'custom_property_history',
+ definitionId: CUSTOM_PROPERTY_ID,
+ windowDays: 30,
+ })
+ expect(plan?.query.sort).toEqual({
+ column: { kind: 'custom_property', definitionId: CUSTOM_PROPERTY_ID },
+ direction: AccountsTableSortDirection.Ascending,
+ })
+ })
+
+ it('uses only the account ID filter for deep-link state', () => {
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ accountIdFilter: RELATIONSHIP_ID,
+ searchQuery: 'ignored',
+ tagsFilter: ['ignored'],
+ allRolesUnassigned: true,
+ })
+ )
+
+ expect(plan?.query.filters).toEqual([{ kind: 'account_id', accountId: RELATIONSHIP_ID }])
+ })
+
+ it.each([
+ ['tile filter', { tileFilter: { tileId: 'tile', expression: 'count > 1' } }],
+ [
+ 'unsupported column',
+ { querySelectColumns: ['name', 'arbitrary_hogql()'], visibleColumnNames: ['name', 'x'] },
+ ],
+ ['misaligned columns', { querySelectColumns: ['name'], visibleColumnNames: ['name', 'extra'] }],
+ ])('falls back to HogQL for %s', (_, overrides) => {
+ expect(buildAccountsTableQueryPlan(queryInput(overrides))).toBeNull()
+ })
+
+ it.each([
+ ['regex', 'currency', PropertyOperator.Regex],
+ ['contains on a number', 'currency', PropertyOperator.IContains],
+ ['comparison on text', 'text', PropertyOperator.GreaterThan],
+ ['date comparison on boolean', 'boolean', PropertyOperator.IsDateBefore],
+ ])('falls back to HogQL for %s custom property filters', (_, displayType, operator) => {
+ const incompatibleDefinition = { ...definition, display_type: displayType } as CustomPropertyDefinitionApi
+
+ expect(
+ buildAccountsTableQueryPlan(
+ queryInput({
+ customPropertyDefinitionsById: { [CUSTOM_PROPERTY_ID]: incompatibleDefinition },
+ customPropertyFilters: [customFilter({ operator })],
+ })
+ )
+ ).toBeNull()
+ })
+
+ it('translates custom property values and history into positional cells', () => {
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ querySelectColumns: [
+ 'name',
+ `accounts.custom_properties.values.\`${CUSTOM_PROPERTY_ID}\` AS cp_value`,
+ `accounts.custom_properties_history.values.\`${CUSTOM_PROPERTY_ID}\` AS cp_history`,
+ ],
+ visibleColumnNames: ['name', 'cp_value', 'cp_history'],
+ columnDisplay: { [CUSTOM_PROPERTY_ID]: { mode: 'trend', window_days: 30 } },
+ })
+ ) as AccountsTableQueryPlan
+
+ const rows = accountsTableRowsToLegacyRows(
+ [
+ {
+ id: 'account-id',
+ name: 'Acme',
+ accountFields: { name: 'Acme' },
+ relationships: {},
+ customProperties: { [CUSTOM_PROPERTY_ID]: 42 },
+ customPropertyHistory: {
+ [CUSTOM_PROPERTY_ID]: [{ timestamp: '2026-01-01T00:00:00Z', value: 40 }],
+ },
+ },
+ ],
+ plan
+ )
+
+ expect(rows).toEqual([[{ id: 'account-id', name: 'Acme', external_id: null }, 42, [[1767225600, 40]]]])
+ })
+
+ it('translates keyed Postgres rows into the positional table response', () => {
+ const plan = buildAccountsTableQueryPlan(queryInput()) as AccountsTableQueryPlan
+ const rows = accountsTableRowsToLegacyRows(
+ [
+ {
+ id: 'account-id',
+ name: 'Acme',
+ externalId: 'acme-1',
+ accountFields: { name: 'Acme' },
+ tags: ['enterprise'],
+ noteCount: 2,
+ relationships: { [RELATIONSHIP_ID]: [42] },
+ customProperties: {},
+ customPropertyHistory: {},
+ },
+ ],
+ plan
+ )
+
+ expect(rows).toEqual([[{ id: 'account-id', name: 'Acme', external_id: 'acme-1' }, ['enterprise'], 2, [42]]])
+ })
+})
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
new file mode 100644
index 000000000000..8fdaadd124bb
--- /dev/null
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
@@ -0,0 +1,317 @@
+import { isUUIDLike } from 'lib/utils/guards'
+
+import {
+ AccountsTableAccountField,
+ AccountsTableAccountIdFilter,
+ AccountsTableAssignedToFilter,
+ AccountsTableColumn,
+ AccountsTableCustomPropertyFilter,
+ AccountsTableCustomPropertyOperator,
+ AccountsTableFilter,
+ AccountsTableQuery,
+ AccountsTableRow,
+ AccountsTableSort,
+ AccountsTableSortDirection,
+ AccountsTableSortableColumn,
+ AccountsTableTagsFilter,
+ AccountsTableUnassignedFilter,
+ NodeKind,
+} from '~/queries/schema/schema-general'
+import { AccountCustomPropertyFilter, PropertyOperator } from '~/types'
+
+import type { CustomPropertyDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+
+import { CUSTOMER_ANALYTICS_DEFAULT_QUERY_TAGS } from '../../constants'
+import { isNumericDisplayType } from '../../scenes/CustomerAnalyticsConfigurationScene/account/customPropertyTypes'
+import type { AccountColumnDisplayState } from './accountsColumnConfigLogic'
+import type { AccountSortOrder, RoleFilterValue } from './accountsLogic'
+import type { TileFilter } from './accountsOverviewTilesLogic'
+
+const RELATIONSHIP_COLUMN_REGEX = /^accounts\.relationships\.values\.`([0-9a-fA-F-]+)` AS [A-Za-z_][\w]*$/
+const CUSTOM_PROPERTY_COLUMN_REGEX = /^accounts\.custom_properties\.values\.`([0-9a-fA-F-]+)` AS [A-Za-z_][\w]*$/
+const CUSTOM_PROPERTY_HISTORY_COLUMN_REGEX =
+ /^accounts\.custom_properties_history\.values\.`([0-9a-fA-F-]+)` AS [A-Za-z_][\w]*$/
+const JSON_ACCOUNT_FIELD_REGEX = /^JSONExtractString\((?:accounts\.)?properties,\s*['"`]([A-Za-z_][\w]*)['"`]\)$/
+
+const ACCOUNT_FIELD_VALUES = new Set<string>(Object.values(AccountsTableAccountField))
+
+const CUSTOM_PROPERTY_OPERATOR_MAP: Partial<Record<PropertyOperator, AccountsTableCustomPropertyOperator>> = {
+ [PropertyOperator.Exact]: AccountsTableCustomPropertyOperator.Exact,
+ [PropertyOperator.IsNot]: AccountsTableCustomPropertyOperator.IsNot,
+ [PropertyOperator.IContains]: AccountsTableCustomPropertyOperator.Contains,
+ [PropertyOperator.NotIContains]: AccountsTableCustomPropertyOperator.DoesNotContain,
+ [PropertyOperator.Regex]: AccountsTableCustomPropertyOperator.Regex,
+ [PropertyOperator.NotRegex]: AccountsTableCustomPropertyOperator.NotRegex,
+ [PropertyOperator.GreaterThan]: AccountsTableCustomPropertyOperator.GreaterThan,
+ [PropertyOperator.GreaterThanOrEqual]: AccountsTableCustomPropertyOperator.GreaterThanOrEqual,
+ [PropertyOperator.LessThan]: AccountsTableCustomPropertyOperator.LessThan,
+ [PropertyOperator.LessThanOrEqual]: AccountsTableCustomPropertyOperator.LessThanOrEqual,
+ [PropertyOperator.IsSet]: AccountsTableCustomPropertyOperator.IsSet,
+ [PropertyOperator.IsNotSet]: AccountsTableCustomPropertyOperator.IsNotSet,
+ [PropertyOperator.IsDateExact]: AccountsTableCustomPropertyOperator.DateExact,
+ [PropertyOperator.IsDateBefore]: AccountsTableCustomPropertyOperator.DateBefore,
+ [PropertyOperator.IsDateAfter]: AccountsTableCustomPropertyOperator.DateAfter,
+}
+
+export interface AccountsTablePlannedColumn {
+ visibleName: string
+ column: AccountsTableColumn
+}
+
+export interface AccountsTableQueryPlan {
+ query: AccountsTableQuery
+ columns: AccountsTablePlannedColumn[]
+}
+
+export interface BuildAccountsTableQueryPlanInput {
+ querySelectColumns: string[]
+ visibleColumnNames: string[]
+ searchQuery: string
+ tagsFilter: string[]
+ allRolesUnassigned: boolean
+ assignedToFilter: RoleFilterValue
+ accountIdFilter: string | null
+ tileFilter: TileFilter | null
+ customPropertyFilters: AccountCustomPropertyFilter[]
+ customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>
+ columnDisplay: AccountColumnDisplayState
+ sortOrder: AccountSortOrder
+ canSortClientSide: boolean
+}
+
+function accountFieldFromExpression(expression: string): AccountsTableAccountField | null {
+ const normalized = expression.trim().replace(/^accounts\./, '')
+ if (ACCOUNT_FIELD_VALUES.has(normalized)) {
+ return normalized as AccountsTableAccountField
+ }
+ const jsonField = expression.trim().match(JSON_ACCOUNT_FIELD_REGEX)?.[1]
+ return jsonField && ACCOUNT_FIELD_VALUES.has(jsonField) ? (jsonField as AccountsTableAccountField) : null
+}
+
+function columnFromExpression(
+ expression: string,
+ columnDisplay: AccountColumnDisplayState
+): AccountsTableColumn | null {
+ if (expression === 'accounts.tags.names AS tag_names') {
+ return { kind: 'tags' }
+ }
+ if (expression === 'accounts.notebooks.count AS notebook_count') {
+ return { kind: 'note_count' }
+ }
+
+ const relationshipDefinitionId = expression.match(RELATIONSHIP_COLUMN_REGEX)?.[1]
+ if (relationshipDefinitionId && isUUIDLike(relationshipDefinitionId)) {
+ return { kind: 'relationship', definitionId: relationshipDefinitionId }
+ }
+ const customPropertyDefinitionId = expression.match(CUSTOM_PROPERTY_COLUMN_REGEX)?.[1]
+ if (customPropertyDefinitionId && isUUIDLike(customPropertyDefinitionId)) {
+ return { kind: 'custom_property', definitionId: customPropertyDefinitionId }
+ }
+ const customPropertyHistoryDefinitionId = expression.match(CUSTOM_PROPERTY_HISTORY_COLUMN_REGEX)?.[1]
+ if (customPropertyHistoryDefinitionId && isUUIDLike(customPropertyHistoryDefinitionId)) {
+ const windowDays = columnDisplay[customPropertyHistoryDefinitionId]?.window_days
+ if (windowDays !== 7 && windowDays !== 14 && windowDays !== 30 && windowDays !== 90) {
+ return null
+ }
+ return {
+ kind: 'custom_property_history',
+ definitionId: customPropertyHistoryDefinitionId,
+ windowDays,
+ }
+ }
+ const accountField = accountFieldFromExpression(expression)
+ return accountField ? { kind: 'account_field', field: accountField } : null
+}
+
+function customPropertyFilter(
+ filter: AccountCustomPropertyFilter,
+ definitionsById: Record<string, CustomPropertyDefinitionApi>
+): AccountsTableCustomPropertyFilter | null {
+ if (!filter.key || !isUUIDLike(filter.key)) {
+ return null
+ }
+ const definition = definitionsById[filter.key]
+ const operator = CUSTOM_PROPERTY_OPERATOR_MAP[filter.operator]
+ if (!definition || !operator) {
+ return null
+ }
+ if (
+ operator === AccountsTableCustomPropertyOperator.Regex ||
+ operator === AccountsTableCustomPropertyOperator.NotRegex
+ ) {
+ return null
+ }
+ if (
+ (operator === AccountsTableCustomPropertyOperator.Contains ||
+ operator === AccountsTableCustomPropertyOperator.DoesNotContain) &&
+ definition.display_type !== 'text' &&
+ definition.display_type !== 'select'
+ ) {
+ return null
+ }
+ if (
+ (operator === AccountsTableCustomPropertyOperator.GreaterThan ||
+ operator === AccountsTableCustomPropertyOperator.GreaterThanOrEqual ||
+ operator === AccountsTableCustomPropertyOperator.LessThan ||
+ operator === AccountsTableCustomPropertyOperator.LessThanOrEqual) &&
+ !isNumericDisplayType(definition.display_type)
+ ) {
+ return null
+ }
+ if (
+ (operator === AccountsTableCustomPropertyOperator.DateExact ||
+ operator === AccountsTableCustomPropertyOperator.DateBefore ||
+ operator === AccountsTableCustomPropertyOperator.DateAfter) &&
+ definition.display_type !== 'date' &&
+ definition.display_type !== 'datetime'
+ ) {
+ return null
+ }
+ const rawValues = Array.isArray(filter.value) ? filter.value : filter.value == null ? [] : [filter.value]
+ const values = rawValues.filter(
+ (value): value is string | number | boolean =>
+ typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
+ )
+ const doesNotNeedValues =
+ operator === AccountsTableCustomPropertyOperator.IsSet ||
+ operator === AccountsTableCustomPropertyOperator.IsNotSet
+ if (!doesNotNeedValues && values.length === 0) {
+ return null
+ }
+ return {
+ kind: 'custom_property',
+ definitionId: filter.key,
+ operator,
+ values,
+ }
+}
+
+function queryFilters(input: BuildAccountsTableQueryPlanInput): AccountsTableFilter[] | null {
+ if (input.accountIdFilter) {
+ return [{ kind: 'account_id', accountId: input.accountIdFilter } satisfies AccountsTableAccountIdFilter]
+ }
+
+ const filters: AccountsTableFilter[] = []
+ const search = input.searchQuery.trim()
+ if (search) {
+ filters.push({ kind: 'search', query: search })
+ }
+ if (input.tagsFilter.length > 0) {
+ filters.push({ kind: 'tags', tagNames: input.tagsFilter } satisfies AccountsTableTagsFilter)
+ }
+ if (input.allRolesUnassigned) {
+ filters.push({ kind: 'unassigned' } satisfies AccountsTableUnassignedFilter)
+ }
+ if (input.assignedToFilter.length > 0) {
+ filters.push({ kind: 'assigned_to', userIds: input.assignedToFilter } satisfies AccountsTableAssignedToFilter)
+ }
+ for (const filter of input.customPropertyFilters) {
+ const translatedFilter = customPropertyFilter(filter, input.customPropertyDefinitionsById)
+ if (!translatedFilter) {
+ return null
+ }
+ filters.push(translatedFilter)
+ }
+ return filters
+}
+
+function sortableColumn(column: AccountsTableColumn): AccountsTableSortableColumn {
+ if (column.kind === 'custom_property_history') {
+ return { kind: 'custom_property', definitionId: column.definitionId }
+ }
+ return column
+}
+
+export function buildAccountsTableQueryPlan(input: BuildAccountsTableQueryPlanInput): AccountsTableQueryPlan | null {
+ if (input.tileFilter || input.querySelectColumns.length !== input.visibleColumnNames.length) {
+ return null
+ }
+
+ const columns: AccountsTablePlannedColumn[] = []
+ for (let index = 0; index < input.querySelectColumns.length; index++) {
+ const column = columnFromExpression(input.querySelectColumns[index], input.columnDisplay)
+ if (!column) {
+ return null
+ }
+ columns.push({ visibleName: input.visibleColumnNames[index], column })
+ }
+
+ let sort: AccountsTableSort | undefined
+ if (input.sortOrder && !input.canSortClientSide) {
+ const plannedColumn = columns.find((column) => column.visibleName === input.sortOrder?.column)
+ if (plannedColumn) {
+ sort = {
+ column: sortableColumn(plannedColumn.column),
+ direction:
+ input.sortOrder.direction === 'asc'
+ ? AccountsTableSortDirection.Ascending
+ : AccountsTableSortDirection.Descending,
+ }
+ }
+ }
+
+ const filters = queryFilters(input)
+ if (!filters) {
+ return null
+ }
+
+ return {
+ query: {
+ kind: NodeKind.AccountsTableQuery,
+ columns: columns.map(({ column }) => column),
+ filters,
+ sort,
+ tags: { ...CUSTOMER_ANALYTICS_DEFAULT_QUERY_TAGS, name: 'customer_analytics_accounts_postgres_list' },
+ },
+ columns,
+ }
+}
+
+function accountFieldValue(row: AccountsTableRow, field: AccountsTableAccountField): unknown {
+ if (field === AccountsTableAccountField.Name) {
+ return { id: row.id, name: row.name, external_id: row.externalId ?? null }
+ }
+ if (field === AccountsTableAccountField.ExternalId) {
+ return row.externalId ?? null
+ }
+ return row.accountFields[field] ?? null
+}
+
+function legacyCellValue(row: AccountsTableRow, column: AccountsTableColumn): unknown {
+ switch (column.kind) {
+ case 'account_field':
+ return accountFieldValue(row, column.field)
+ case 'tags':
+ return row.tags ?? []
+ case 'note_count':
+ return row.noteCount ?? 0
+ case 'relationship':
+ return row.relationships[column.definitionId] ?? []
+ case 'custom_property':
+ return row.customProperties[column.definitionId] ?? null
+ case 'custom_property_history':
+ return (row.customPropertyHistory[column.definitionId] ?? []).map((point): [number, number] => [
+ Math.floor(Date.parse(point.timestamp) / 1000),
+ point.value,
+ ])
+ }
+}
+
+export function isAccountsTableRow(value: unknown): value is AccountsTableRow {
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
+ return false
+ }
+ const row = value as Partial<AccountsTableRow>
+ return (
+ typeof row.id === 'string' &&
+ typeof row.name === 'string' &&
+ !!row.accountFields &&
+ !!row.relationships &&
+ !!row.customProperties &&
+ !!row.customPropertyHistory
+ )
+}
+
+export function accountsTableRowsToLegacyRows(rows: AccountsTableRow[], plan: AccountsTableQueryPlan): unknown[][] {
+ return rows.map((row) => plan.columns.map(({ column }) => legacyCellValue(row, column)))
+}
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
index 022314543d32..0523335b2f0d 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
@@ -2,9 +2,12 @@ import { MOCK_DEFAULT_TEAM, MOCK_DEFAULT_USER } from '~/lib/api.mock'
import { expectLogic } from 'kea-test-utils'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { userLogic } from 'scenes/userLogic'
import { useMocks } from '~/mocks/jest'
+import type { AccountsTableQuery } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
import { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
@@ -97,6 +100,32 @@ describe('accountsViewsLogic', () => {
expect(logic.values.currentViewId).toEqual('view-1')
})
+ it('translates an applied saved view into the Postgres query', async () => {
+ useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES], {
+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNTS_POSTGRES]: true,
+ })
+ mountAll()
+ await expectLogic(logic, () =>
+ logic.actions.applyView(
+ buildView({
+ columns: ['name'],
+ filters: { search: 'acme', tags: ['enterprise'], assignedTo: [1, 2] },
+ order_by: ['name DESC'],
+ })
+ )
+ ).toFinishAllListeners()
+
+ const source = accountsLogic.values.accountsQuerySource as AccountsTableQuery
+ expect(source.kind).toBe('AccountsTableQuery')
+ expect(source.columns).toEqual([{ kind: 'account_field', field: 'name' }])
+ expect(source.filters).toEqual([
+ { kind: 'search', query: 'acme' },
+ { kind: 'tags', tagNames: ['enterprise'] },
+ { kind: 'assigned_to', userIds: [1, 2] },
+ ])
+ })
+
it('isDirty flips when live state diverges from the applied view and clears on re-apply', async () => {
useMocks({
get: {
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index bc5cf15379ee..9f736d5df829 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -5048,6 +5048,75 @@ export interface Response22Api {
warnings?: (DataWarehouseSyncWarningApi | AccessControlFilterWarningApi)[] | null
}
+export interface AccountsTableCustomPropertyHistoryPointApi {
+ timestamp: string
+ value: number
+}
+
+/**
+ * Requested direct Account fields, keyed by their typed field reference.
+ */
+export type AccountsTableRowApiAccountFields = { [key: string]: string | null }
+
+/**
+ * Current values keyed by requested custom property definition ID.
+ */
+export type AccountsTableRowApiCustomProperties = { [key: string]: string | number | boolean | null }
+
+/**
+ * Numeric write history keyed by requested custom property definition ID.
+ */
+export type AccountsTableRowApiCustomPropertyHistory = { [key: string]: AccountsTableCustomPropertyHistoryPointApi[] }
+
+/**
+ * Active assignee user IDs keyed by requested relationship definition ID.
+ */
+export type AccountsTableRowApiRelationships = { [key: string]: number[] }
+
+export interface AccountsTableRowApi {
+ /** Requested direct Account fields, keyed by their typed field reference. */
+ accountFields: AccountsTableRowApiAccountFields
+ /** Current values keyed by requested custom property definition ID. */
+ customProperties: AccountsTableRowApiCustomProperties
+ /** Numeric write history keyed by requested custom property definition ID. */
+ customPropertyHistory: AccountsTableRowApiCustomPropertyHistory
+ externalId?: string | null
+ id: string
+ name: string
+ /** Number of linked internal notes. Omitted when the request does not select the note count. */
+ noteCount?: number | null
+ /** Active assignee user IDs keyed by requested relationship definition ID. */
+ relationships: AccountsTableRowApiRelationships
+ /** Sorted tag names. Omitted when the request does not select tags. */
+ tags?: string[] | null
+}
+
+export interface Response23Api {
+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
+ error?: string | null
+ hasMore: boolean
+ /** Generated HogQL query. */
+ hogql?: string | null
+ kind?: 'AccountsTableQuery'
+ 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 resolved previous/comparison period date range, when comparing against another period */
+ resolved_compare_date_range?: ResolvedDateRangeResponseApi | null
+ /** The date range used for the query */
+ resolved_date_range?: ResolvedDateRangeResponseApi | null
+ results: AccountsTableRowApi[]
+ /** Measured timings for different parts of the query generation process */
+ timings?: QueryTimingApi[] | null
+ /** Connector-synced data warehouse sources referenced by this query, if any. */
+ used_data_warehouse_sources?: DataWarehouseSourceUsageApi[] | 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. Also carries access control warnings when a system-table query filters out objects the user can't access. */
+ warnings?: (DataWarehouseSyncWarningApi | AccessControlFilterWarningApi)[] | null
+}
+
export type TaxonomicFilterGroupTypeApi = (typeof TaxonomicFilterGroupTypeApi)[keyof typeof TaxonomicFilterGroupTypeApi]
export const TaxonomicFilterGroupTypeApi = {
@@ -7842,6 +7911,199 @@ export interface AccountsQueryApi {
version?: number | null
}
+export type AccountsTableAccountFieldApi =
+ (typeof AccountsTableAccountFieldApi)[keyof typeof AccountsTableAccountFieldApi]
+
+export const AccountsTableAccountFieldApi = {
+ Name: 'name',
+ ExternalId: 'external_id',
+ CreatedAt: 'created_at',
+ UpdatedAt: 'updated_at',
+ StripeCustomerId: 'stripe_customer_id',
+ HubspotDealId: 'hubspot_deal_id',
+ BillingId: 'billing_id',
+ SfdcId: 'sfdc_id',
+ ZendeskId: 'zendesk_id',
+} as const
+
+export interface AccountsTableAccountFieldColumnApi {
+ field: AccountsTableAccountFieldApi
+ kind?: 'account_field'
+}
+
+export const AccountsTableTagsColumnApiValue = {
+ kind: 'tags',
+} as const
+export type AccountsTableTagsColumnApi = typeof AccountsTableTagsColumnApiValue
+
+export const AccountsTableNoteCountColumnApiValue = {
+ kind: 'note_count',
+} as const
+export type AccountsTableNoteCountColumnApi = typeof AccountsTableNoteCountColumnApiValue
+
+export interface AccountsTableRelationshipColumnApi {
+ /** Team-scoped relationship definition to return for each account. */
+ definitionId: string
+ kind?: 'relationship'
+}
+
+export interface AccountsTableCustomPropertyColumnApi {
+ /** Team-scoped custom property definition to return for each account. */
+ definitionId: string
+ kind?: 'custom_property'
+}
+
+export type WindowDaysApi = (typeof WindowDaysApi)[keyof typeof WindowDaysApi]
+
+export const WindowDaysApi = {
+ Number7: 7,
+ Number14: 14,
+ Number30: 30,
+ Number90: 90,
+} as const
+
+export interface AccountsTableCustomPropertyHistoryColumnApi {
+ /** Team-scoped numeric custom property definition whose write history should be returned. */
+ definitionId: string
+ kind?: 'custom_property_history'
+ /** Number of days of history to return. The current value is included even when it is older. */
+ windowDays: WindowDaysApi
+}
+
+export interface AccountsTableSearchFilterApi {
+ kind?: 'search'
+ query: string
+}
+
+export interface AccountsTableTagsFilterApi {
+ kind?: 'tags'
+ /** Match accounts carrying any of these tag names. */
+ tagNames: string[]
+}
+
+export interface AccountsTableAssignedToFilterApi {
+ kind?: 'assigned_to'
+ /** Match accounts where any listed user actively holds any relationship. */
+ userIds: number[]
+}
+
+export const AccountsTableUnassignedFilterApiValue = {
+ kind: 'unassigned',
+} as const
+export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
+
+export interface AccountsTableAccountIdFilterApi {
+ accountId: string
+ kind?: 'account_id'
+}
+
+export type AccountsTableCustomPropertyOperatorApi =
+ (typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
+
+export const AccountsTableCustomPropertyOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ Icontains: 'icontains',
+ NotIcontains: 'not_icontains',
+ Regex: 'regex',
+ NotRegex: 'not_regex',
+ Gt: 'gt',
+ Gte: 'gte',
+ Lt: 'lt',
+ Lte: 'lte',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+ IsDateExact: 'is_date_exact',
+ IsDateBefore: 'is_date_before',
+ IsDateAfter: 'is_date_after',
+} as const
+
+export interface AccountsTableCustomPropertyFilterApi {
+ definitionId: string
+ kind?: 'custom_property'
+ operator: AccountsTableCustomPropertyOperatorApi
+ /** Values interpreted according to the custom property definition's display type. */
+ values?: (string | number | boolean)[] | null
+}
+
+export interface AccountsTableQueryResponseApi {
+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
+ error?: string | null
+ hasMore: boolean
+ /** Generated HogQL query. */
+ hogql?: string | null
+ kind?: 'AccountsTableQuery'
+ 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 resolved previous/comparison period date range, when comparing against another period */
+ resolved_compare_date_range?: ResolvedDateRangeResponseApi | null
+ /** The date range used for the query */
+ resolved_date_range?: ResolvedDateRangeResponseApi | null
+ results: AccountsTableRowApi[]
+ /** Measured timings for different parts of the query generation process */
+ timings?: QueryTimingApi[] | null
+ /** Connector-synced data warehouse sources referenced by this query, if any. */
+ used_data_warehouse_sources?: DataWarehouseSourceUsageApi[] | 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. Also carries access control warnings when a system-table query filters out objects the user can't access. */
+ warnings?: (DataWarehouseSyncWarningApi | AccessControlFilterWarningApi)[] | null
+}
+
+export type AccountsTableSortDirectionApi =
+ (typeof AccountsTableSortDirectionApi)[keyof typeof AccountsTableSortDirectionApi]
+
+export const AccountsTableSortDirectionApi = {
+ Asc: 'asc',
+ Desc: 'desc',
+} as const
+
+export interface AccountsTableSortApi {
+ /** A typed column that supports server-side sorting. */
+ column:
+ | AccountsTableAccountFieldColumnApi
+ | AccountsTableTagsColumnApi
+ | AccountsTableNoteCountColumnApi
+ | AccountsTableRelationshipColumnApi
+ | AccountsTableCustomPropertyColumnApi
+ direction: AccountsTableSortDirectionApi
+}
+
+export interface AccountsTableQueryApi {
+ /** Columns to load for each account. Account identity fields are always returned. */
+ columns: (
+ | AccountsTableAccountFieldColumnApi
+ | AccountsTableTagsColumnApi
+ | AccountsTableNoteCountColumnApi
+ | AccountsTableRelationshipColumnApi
+ | AccountsTableCustomPropertyColumnApi
+ | AccountsTableCustomPropertyHistoryColumnApi
+ )[]
+ /** Filters are combined with AND. Values within tag and assignment filters use OR. */
+ filters?:
+ | (
+ | AccountsTableSearchFilterApi
+ | AccountsTableTagsFilterApi
+ | AccountsTableAssignedToFilterApi
+ | AccountsTableUnassignedFilterApi
+ | AccountsTableAccountIdFilterApi
+ | AccountsTableCustomPropertyFilterApi
+ )[]
+ | null
+ kind?: 'AccountsTableQuery'
+ limit?: number | null
+ /** Modifiers used when performing the query */
+ modifiers?: HogQLQueryModifiersApi | null
+ offset?: number | null
+ response?: AccountsTableQueryResponseApi | null
+ sort?: AccountsTableSortApi | null
+ tags?: QueryLogTagsApi | null
+ /** version of the node, used for schema migrations */
+ version?: number | null
+}
+
export type DataTableNodeApiResponse =
| { [key: string]: unknown }
| ResponseApi
@@ -7866,6 +8128,7 @@ export type DataTableNodeApiResponse =
| Response19Api
| Response21Api
| Response22Api
+ | Response23Api
| null
export interface DataTableNodeApi {
@@ -7968,6 +8231,7 @@ export interface DataTableNodeApi {
| SessionQueryApi
| EndpointsUsageTableQueryApi
| AccountsQueryApi
+ | AccountsTableQueryApi
tags?: QueryLogTagsApi | null
/** version of the node, used for schema migrations */
version?: number | null
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 951c45a0523e..094811506c4f 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -4378,6 +4378,75 @@ export interface Response22Api {
warnings?: (DataWarehouseSyncWarningApi | AccessControlFilterWarningApi)[] | null
}
+export interface AccountsTableCustomPropertyHistoryPointApi {
+ timestamp: string
+ value: number
+}
+
+/**
+ * Requested direct Account fields, keyed by their typed field reference.
+ */
+export type AccountsTableRowApiAccountFields = { [key: string]: string | null }
+
+/**
+ * Current values keyed by requested custom property definition ID.
+ */
+export type AccountsTableRowApiCustomProperties = { [key: string]: string | number | boolean | null }
+
+/**
+ * Numeric write history keyed by requested custom property definition ID.
+ */
+export type AccountsTableRowApiCustomPropertyHistory = { [key: string]: AccountsTableCustomPropertyHistoryPointApi[] }
+
+/**
+ * Active assignee user IDs keyed by requested relationship definition ID.
+ */
+export type AccountsTableRowApiRelationships = { [key: string]: number[] }
+
+export interface AccountsTableRowApi {
+ /** Requested direct Account fields, keyed by their typed field reference. */
+ accountFields: AccountsTableRowApiAccountFields
+ /** Current values keyed by requested custom property definition ID. */
+ customProperties: AccountsTableRowApiCustomProperties
+ /** Numeric write history keyed by requested custom property definition ID. */
+ customPropertyHistory: AccountsTableRowApiCustomPropertyHistory
+ externalId?: string | null
+ id: string
+ name: string
+ /** Number of linked internal notes. Omitted when the request does not select the note count. */
+ noteCount?: number | null
+ /** Active assignee user IDs keyed by requested relationship definition ID. */
+ relationships: AccountsTableRowApiRelationships
+ /** Sorted tag names. Omitted when the request does not select tags. */
+ tags?: string[] | null
+}
+
+export interface Response23Api {
+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
+ error?: string | null
+ hasMore: boolean
+ /** Generated HogQL query. */
+ hogql?: string | null
+ kind?: 'AccountsTableQuery'
+ 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 resolved previous/comparison period date range, when comparing against another period */
+ resolved_compare_date_range?: ResolvedDateRangeResponseApi | null
+ /** The date range used for the query */
+ resolved_date_range?: ResolvedDateRangeResponseApi | null
+ results: AccountsTableRowApi[]
+ /** Measured timings for different parts of the query generation process */
+ timings?: QueryTimingApi[] | null
+ /** Connector-synced data warehouse sources referenced by this query, if any. */
+ used_data_warehouse_sources?: DataWarehouseSourceUsageApi[] | 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. Also carries access control warnings when a system-table query filters out objects the user can't access. */
+ warnings?: (DataWarehouseSyncWarningApi | AccessControlFilterWarningApi)[] | null
+}
+
export type TaxonomicFilterGroupTypeApi = (typeof TaxonomicFilterGroupTypeApi)[keyof typeof TaxonomicFilterGroupTypeApi]
export const TaxonomicFilterGroupTypeApi = {
@@ -7172,6 +7241,199 @@ export interface AccountsQueryApi {
version?: number | null
}
+export type AccountsTableAccountFieldApi =
+ (typeof AccountsTableAccountFieldApi)[keyof typeof AccountsTableAccountFieldApi]
+
+export const AccountsTableAccountFieldApi = {
+ Name: 'name',
+ ExternalId: 'external_id',
+ CreatedAt: 'created_at',
+ UpdatedAt: 'updated_at',
+ StripeCustomerId: 'stripe_customer_id',
+ HubspotDealId: 'hubspot_deal_id',
+ BillingId: 'billing_id',
+ SfdcId: 'sfdc_id',
+ ZendeskId: 'zendesk_id',
+} as const
+
+export interface AccountsTableAccountFieldColumnApi {
+ field: AccountsTableAccountFieldApi
+ kind?: 'account_field'
+}
+
+export const AccountsTableTagsColumnApiValue = {
+ kind: 'tags',
+} as const
+export type AccountsTableTagsColumnApi = typeof AccountsTableTagsColumnApiValue
+
+export const AccountsTableNoteCountColumnApiValue = {
+ kind: 'note_count',
+} as const
+export type AccountsTableNoteCountColumnApi = typeof AccountsTableNoteCountColumnApiValue
+
+export interface AccountsTableRelationshipColumnApi {
+ /** Team-scoped relationship definition to return for each account. */
+ definitionId: string
+ kind?: 'relationship'
+}
+
+export interface AccountsTableCustomPropertyColumnApi {
+ /** Team-scoped custom property definition to return for each account. */
+ definitionId: string
+ kind?: 'custom_property'
+}
+
+export type WindowDaysApi = (typeof WindowDaysApi)[keyof typeof WindowDaysApi]
+
+export const WindowDaysApi = {
+ Number7: 7,
+ Number14: 14,
+ Number30: 30,
+ Number90: 90,
+} as const
+
+export interface AccountsTableCustomPropertyHistoryColumnApi {
+ /** Team-scoped numeric custom property definition whose write history should be returned. */
+ definitionId: string
+ kind?: 'custom_property_history'
+ /** Number of days of history to return. The current value is included even when it is older. */
+ windowDays: WindowDaysApi
+}
+
+export interface AccountsTableSearchFilterApi {
+ kind?: 'search'
+ query: string
+}
+
+export interface AccountsTableTagsFilterApi {
+ kind?: 'tags'
+ /** Match accounts carrying any of these tag names. */
+ tagNames: string[]
+}
+
+export interface AccountsTableAssignedToFilterApi {
+ kind?: 'assigned_to'
+ /** Match accounts where any listed user actively holds any relationship. */
+ userIds: number[]
+}
+
+export const AccountsTableUnassignedFilterApiValue = {
+ kind: 'unassigned',
+} as const
+export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
+
+export interface AccountsTableAccountIdFilterApi {
+ accountId: string
+ kind?: 'account_id'
+}
+
+export type AccountsTableCustomPropertyOperatorApi =
+ (typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
+
+export const AccountsTableCustomPropertyOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ Icontains: 'icontains',
+ NotIcontains: 'not_icontains',
+ Regex: 'regex',
+ NotRegex: 'not_regex',
+ Gt: 'gt',
+ Gte: 'gte',
+ Lt: 'lt',
+ Lte: 'lte',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+ IsDateExact: 'is_date_exact',
+ IsDateBefore: 'is_date_before',
+ IsDateAfter: 'is_date_after',
+} as const
+
+export interface AccountsTableCustomPropertyFilterApi {
+ definitionId: string
+ kind?: 'custom_property'
+ operator: AccountsTableCustomPropertyOperatorApi
+ /** Values interpreted according to the custom property definition's display type. */
+ values?: (string | number | boolean)[] | null
+}
+
+export interface AccountsTableQueryResponseApi {
+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
+ error?: string | null
+ hasMore: boolean
+ /** Generated HogQL query. */
+ hogql?: string | null
+ kind?: 'AccountsTableQuery'
+ 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 resolved previous/comparison period date range, when comparing against another period */
+ resolved_compare_date_range?: ResolvedDateRangeResponseApi | null
+ /** The date range used for the query */
+ resolved_date_range?: ResolvedDateRangeResponseApi | null
+ results: AccountsTableRowApi[]
+ /** Measured timings for different parts of the query generation process */
+ timings?: QueryTimingApi[] | null
+ /** Connector-synced data warehouse sources referenced by this query, if any. */
+ used_data_warehouse_sources?: DataWarehouseSourceUsageApi[] | 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. Also carries access control warnings when a system-table query filters out objects the user can't access. */
+ warnings?: (DataWarehouseSyncWarningApi | AccessControlFilterWarningApi)[] | null
+}
+
+export type AccountsTableSortDirectionApi =
+ (typeof AccountsTableSortDirectionApi)[keyof typeof AccountsTableSortDirectionApi]
+
+export const AccountsTableSortDirectionApi = {
+ Asc: 'asc',
+ Desc: 'desc',
+} as const
+
+export interface AccountsTableSortApi {
+ /** A typed column that supports server-side sorting. */
+ column:
+ | AccountsTableAccountFieldColumnApi
+ | AccountsTableTagsColumnApi
+ | AccountsTableNoteCountColumnApi
+ | AccountsTableRelationshipColumnApi
+ | AccountsTableCustomPropertyColumnApi
+ direction: AccountsTableSortDirectionApi
+}
+
+export interface AccountsTableQueryApi {
+ /** Columns to load for each account. Account identity fields are always returned. */
+ columns: (
+ | AccountsTableAccountFieldColumnApi
+ | AccountsTableTagsColumnApi
+ | AccountsTableNoteCountColumnApi
+ | AccountsTableRelationshipColumnApi
+ | AccountsTableCustomPropertyColumnApi
+ | AccountsTableCustomPropertyHistoryColumnApi
+ )[]
+ /** Filters are combined with AND. Values within tag and assignment filters use OR. */
+ filters?:
+ | (
+ | AccountsTableSearchFilterApi
+ | AccountsTableTagsFilterApi
+ | AccountsTableAssignedToFilterApi
+ | AccountsTableUnassignedFilterApi
+ | AccountsTableAccountIdFilterApi
+ | AccountsTableCustomPropertyFilterApi
+ )[]
+ | null
+ kind?: 'AccountsTableQuery'
+ limit?: number | null
+ /** Modifiers used when performing the query */
+ modifiers?: HogQLQueryModifiersApi | null
+ offset?: number | null
+ response?: AccountsTableQueryResponseApi | null
+ sort?: AccountsTableSortApi | null
+ tags?: QueryLogTagsApi | null
+ /** version of the node, used for schema migrations */
+ version?: number | null
+}
+
export type DataTableNodeApiResponse =
| { [key: string]: unknown }
| ResponseApi
@@ -7196,6 +7458,7 @@ export type DataTableNodeApiResponse =
| Response19Api
| Response21Api
| Response22Api
+ | Response23Api
| null
export interface DataTableNodeApi {
@@ -7298,6 +7561,7 @@ export interface DataTableNodeApi {
| SessionQueryApi
| EndpointsUsageTableQueryApi
| AccountsQueryApi
+ | AccountsTableQueryApi
tags?: QueryLogTagsApi | null
/** version of the node, used for schema migrations */
version?: number | null
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 3d9565a267be..5b34bad038fb 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -6348,6 +6348,32 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
+ export interface Response23 {
+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
+ error?: string | null;
+ hasMore: boolean;
+ /** Generated HogQL query. */
+ hogql?: string | null;
+ kind?: 'AccountsTableQuery';
+ 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 resolved previous/comparison period date range, when comparing against another period */
+ resolved_compare_date_range?: ResolvedDateRangeResponse | null;
+ /** The date range used for the query */
+ resolved_date_range?: ResolvedDateRangeResponse | null;
+ results: AccountsTableRow[];
+ /** Measured timings for different parts of the query generation process */
+ timings?: QueryTiming[] | null;
+ /** Connector-synced data warehouse sources referenced by this query, if any. */
+ used_data_warehouse_sources?: DataWarehouseSourceUsage[] | 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. Also carries access control warnings when a system-table query filters out objects the user can't access. */
+ warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
+ }
+
export type TaxonomicFilterGroupType = typeof TaxonomicFilterGroupType[keyof typeof TaxonomicFilterGroupType];
@@ -7774,7 +7800,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 | Response17 | Response18 | Response19 | Response21 | Response22 | null;
+ export type DataTableNodeResponse = { [key: string]: unknown } | Response | Response1 | Response2 | Response3 | Response4 | Response5 | Response6 | Response7 | Response8 | Response9 | Response10 | Response11 | Response12 | Response13 | Response14 | Response15 | Response16 | Response17 | Response18 | Response19 | Response21 | Response22 | Response23 | null;
export interface DataTableNode {
/** Can the user click on column headers to sort the table? (default: true) */
@@ -7848,7 +7874,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 | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | SessionAttributionExplorerQuery | SessionsQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | ErrorTrackingQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | TracesQuery | TraceQuery | SessionQuery | EndpointsUsageTableQuery | AccountsQuery;
+ source: EventsNode | EventsQuery | PersonsNode | ActorsQuery | GroupsQuery | HogQLQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | SessionAttributionExplorerQuery | SessionsQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | ErrorTrackingQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | TracesQuery | TraceQuery | SessionQuery | EndpointsUsageTableQuery | AccountsQuery | AccountsTableQuery;
tags?: QueryLogTags | null;
/** version of the node, used for schema migrations */
version?: number | null;
@@ -64779,9 +64805,35 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export type QueryResponseAlternative58ResultsItem = { [key: string]: unknown };
-
export interface QueryResponseAlternative58 {
+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
+ error?: string | null;
+ hasMore: boolean;
+ /** Generated HogQL query. */
+ hogql?: string | null;
+ kind?: 'AccountsTableQuery';
+ 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 resolved previous/comparison period date range, when comparing against another period */
+ resolved_compare_date_range?: ResolvedDateRangeResponse | null;
+ /** The date range used for the query */
+ resolved_date_range?: ResolvedDateRangeResponse | null;
+ results: AccountsTableRow[];
+ /** Measured timings for different parts of the query generation process */
+ timings?: QueryTiming[] | null;
+ /** Connector-synced data warehouse sources referenced by this query, if any. */
+ used_data_warehouse_sources?: DataWarehouseSourceUsage[] | 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. Also carries access control warnings when a system-table query filters out objects the user can't access. */
+ warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
+ }
+
+ export type QueryResponseAlternative59ResultsItem = { [key: string]: unknown };
+
+ export interface QueryResponseAlternative59 {
boxplot_data?: BoxPlotDatum[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -64797,7 +64849,7 @@ export namespace Schemas {
resolved_compare_date_range?: ResolvedDateRangeResponse | null;
/** The date range used for the query */
resolved_date_range?: ResolvedDateRangeResponse | null;
- results: QueryResponseAlternative58ResultsItem[];
+ results: QueryResponseAlternative59ResultsItem[];
/** Measured timings for different parts of the query generation process */
timings?: QueryTiming[] | null;
/** Connector-synced data warehouse sources referenced by this query, if any. */
@@ -64806,7 +64858,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative59 {
+ export interface QueryResponseAlternative60 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -64830,7 +64882,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative60 {
+ export interface QueryResponseAlternative61 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -64852,7 +64904,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative61 {
+ export interface QueryResponseAlternative62 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -64874,7 +64926,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative62 {
+ export interface QueryResponseAlternative63 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -64896,9 +64948,9 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export type QueryResponseAlternative63ResultsItem = { [key: string]: unknown };
+ export type QueryResponseAlternative64ResultsItem = { [key: string]: unknown };
- export interface QueryResponseAlternative63 {
+ export interface QueryResponseAlternative64 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -64911,7 +64963,7 @@ export namespace Schemas {
resolved_compare_date_range?: ResolvedDateRangeResponse | null;
/** The date range used for the query */
resolved_date_range?: ResolvedDateRangeResponse | null;
- results: QueryResponseAlternative63ResultsItem[];
+ results: QueryResponseAlternative64ResultsItem[];
/** Measured timings for different parts of the query generation process */
timings?: QueryTiming[] | null;
/** Connector-synced data warehouse sources referenced by this query, if any. */
@@ -64920,7 +64972,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative65 {
+ export interface QueryResponseAlternative66 {
columns?: unknown[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -64947,14 +64999,14 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export type QueryResponseAlternative66Tables = {[key: string]: DatabaseSchemaPostHogTable | DatabaseSchemaSystemTable | DatabaseSchemaDataWarehouseTable | DatabaseSchemaViewTable | DatabaseSchemaManagedViewTable | DatabaseSchemaBatchExportTable | DatabaseSchemaMaterializedViewTable | DatabaseSchemaEndpointTable};
+ export type QueryResponseAlternative67Tables = {[key: string]: DatabaseSchemaPostHogTable | DatabaseSchemaSystemTable | DatabaseSchemaDataWarehouseTable | DatabaseSchemaViewTable | DatabaseSchemaManagedViewTable | DatabaseSchemaBatchExportTable | DatabaseSchemaMaterializedViewTable | DatabaseSchemaEndpointTable};
- export interface QueryResponseAlternative66 {
+ export interface QueryResponseAlternative67 {
joins: DataWarehouseViewLink[];
- tables: QueryResponseAlternative66Tables;
+ tables: QueryResponseAlternative67Tables;
}
- export interface QueryResponseAlternative67 {
+ export interface QueryResponseAlternative68 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
has_next: boolean;
@@ -64979,7 +65031,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative68 {
+ export interface QueryResponseAlternative69 {
columns?: string[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -65007,7 +65059,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative69 {
+ export interface QueryResponseAlternative70 {
count: number;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -65030,7 +65082,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- 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. */
@@ -65052,7 +65104,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative71 {
+ export interface QueryResponseAlternative72 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65074,7 +65126,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative72 {
+ export interface QueryResponseAlternative73 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
hasMore?: boolean | null;
@@ -65101,7 +65153,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative73 {
+ export interface QueryResponseAlternative74 {
/** 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. */
@@ -65125,7 +65177,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative74 {
+ export interface QueryResponseAlternative75 {
/** 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. */
@@ -65149,7 +65201,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative75 {
+ export interface QueryResponseAlternative76 {
/** Result rows for the comparison period when `compareFilter.compare` is true. */
compare?: AttributeBreakdownRow[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
@@ -65173,13 +65225,13 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative76 {
+ export interface QueryResponseAlternative77 {
questions: string[];
/** Data warehouse sync warnings — see AnalyticsQueryResponseBase.warnings for semantics. */
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;
hasMore?: boolean | null;
@@ -65204,7 +65256,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | 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;
@@ -65229,7 +65281,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative79 {
+ export interface QueryResponseAlternative80 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65251,7 +65303,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative80 {
+ export interface QueryResponseAlternative81 {
columns?: string[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -65277,7 +65329,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative83 {
+ export interface QueryResponseAlternative84 {
/** Timestamp of the newer trace */
newerTimestamp?: string | null;
/** ID of the newer trace (chronologically after current) */
@@ -65292,7 +65344,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. */
@@ -65314,7 +65366,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative85 {
+ export interface QueryResponseAlternative86 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65336,7 +65388,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative86 {
+ export interface QueryResponseAlternative87 {
columns: unknown[];
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -65366,7 +65418,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative87 {
+ export interface QueryResponseAlternative88 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
hasMore: boolean;
@@ -65392,7 +65444,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | 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. */
@@ -65414,7 +65466,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative89 {
+ export interface QueryResponseAlternative90 {
columns?: unknown[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
@@ -65441,9 +65493,9 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export type QueryResponseAlternative90ResultsItem = { [key: string]: unknown };
+ export type QueryResponseAlternative91ResultsItem = { [key: string]: unknown };
- export interface QueryResponseAlternative90 {
+ export interface QueryResponseAlternative91 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65456,7 +65508,7 @@ export namespace Schemas {
resolved_compare_date_range?: ResolvedDateRangeResponse | null;
/** The date range used for the query */
resolved_date_range?: ResolvedDateRangeResponse | null;
- results: QueryResponseAlternative90ResultsItem[];
+ results: QueryResponseAlternative91ResultsItem[];
/** Measured timings for different parts of the query generation process */
timings?: QueryTiming[] | null;
/** Connector-synced data warehouse sources referenced by this query, if any. */
@@ -65465,7 +65517,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative91 {
+ export interface QueryResponseAlternative92 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65487,7 +65539,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative92 {
+ export interface QueryResponseAlternative93 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65509,7 +65561,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative93 {
+ export interface QueryResponseAlternative94 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65531,7 +65583,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative94 {
+ export interface QueryResponseAlternative95 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65553,7 +65605,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative95 {
+ export interface QueryResponseAlternative96 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65575,7 +65627,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative96 {
+ export interface QueryResponseAlternative97 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65597,7 +65649,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative97 {
+ export interface QueryResponseAlternative98 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65620,7 +65672,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative98 {
+ export interface QueryResponseAlternative99 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65642,7 +65694,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative99 {
+ export interface QueryResponseAlternative100 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65664,7 +65716,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative100 {
+ export interface QueryResponseAlternative101 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65686,7 +65738,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative101 {
+ export interface QueryResponseAlternative102 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65708,7 +65760,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative102 {
+ export interface QueryResponseAlternative103 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65730,7 +65782,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative103 {
+ export interface QueryResponseAlternative104 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65752,7 +65804,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative104 {
+ export interface QueryResponseAlternative105 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65774,7 +65826,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative105 {
+ export interface QueryResponseAlternative106 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65796,7 +65848,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export interface QueryResponseAlternative106 {
+ export interface QueryResponseAlternative107 {
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string | null;
/** Generated HogQL query. */
@@ -65818,7 +65870,7 @@ export namespace Schemas {
warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;
}
- export type QueryResponseAlternative = { [key: string]: unknown } | QueryResponseAlternative1 | QueryResponseAlternative2 | QueryResponseAlternative3 | QueryResponseAlternative4 | QueryResponseAlternative5 | QueryResponseAlternative6 | QueryResponseAlternative7 | QueryResponseAlternative8 | QueryResponseAlternative9 | QueryResponseAlternative10 | QueryResponseAlternative11 | QueryResponseAlternative12 | QueryResponseAlternative13 | QueryResponseAlternative14 | QueryResponseAlternative15 | QueryResponseAlternative16 | QueryResponseAlternative17 | QueryResponseAlternative18 | QueryResponseAlternative19 | QueryResponseAlternative20 | QueryResponseAlternative21 | QueryResponseAlternative22 | QueryResponseAlternative23 | QueryResponseAlternative24 | QueryResponseAlternative25 | QueryResponseAlternative26 | QueryResponseAlternative27 | QueryResponseAlternative28 | QueryResponseAlternative29 | QueryResponseAlternative30 | QueryResponseAlternative31 | QueryResponseAlternative32 | QueryResponseAlternative33 | QueryResponseAlternative34 | unknown | QueryResponseAlternative35 | QueryResponseAlternative36 | QueryResponseAlternative37 | QueryResponseAlternative38 | QueryResponseAlternative39 | QueryResponseAlternative40 | QueryResponseAlternative41 | QueryResponseAlternative42 | QueryResponseAlternative43 | QueryResponseAlternative44 | QueryResponseAlternative45 | QueryResponseAlternative46 | QueryResponseAlternative47 | QueryResponseAlternative48 | QueryResponseAlternative49 | QueryResponseAlternative50 | QueryResponseAlternative52 | QueryResponseAlternative53 | QueryResponseAlternative54 | QueryResponseAlternative56 | QueryResponseAlternative57 | QueryResponseAlternative58 | QueryResponseAlternative59 | QueryResponseAlternative60 | QueryResponseAlternative61 | QueryResponseAlternative62 | QueryResponseAlternative63 | QueryResponseAlternative65 | QueryResponseAlternative66 | QueryResponseAlternative67 | QueryResponseAlternative68 | QueryResponseAlternative69 | QueryResponseAlternative70 | QueryResponseAlternative71 | QueryResponseAlternative72 | QueryResponseAlternative73 | QueryResponseAlternative74 | QueryResponseAlternative75 | QueryResponseAlternative76 | QueryResponseAlternative77 | QueryResponseAlternative78 | QueryResponseAlternative79 | QueryResponseAlternative80 | QueryResponseAlternative83 | QueryResponseAlternative84 | QueryResponseAlternative85 | QueryResponseAlternative86 | QueryResponseAlternative87 | QueryResponseAlternative88 | QueryResponseAlternative89 | QueryResponseAlternative90 | QueryResponseAlternative91 | QueryResponseAlternative92 | QueryResponseAlternative93 | QueryResponseAlternative94 | QueryResponseAlternative95 | QueryResponseAlternative96 | QueryResponseAlternative97 | QueryResponseAlternative98 | QueryResponseAlternative99 | QueryResponseAlternative100 | QueryResponseAlternative101 | QueryResponseAlternative102 | QueryResponseAlternative103 | QueryResponseAlternative104 | QueryResponseAlternative105 | QueryResponseAlternative106;
+ export type QueryResponseAlternative = { [key: string]: unknown } | QueryResponseAlternative1 | QueryResponseAlternative2 | QueryResponseAlternative3 | QueryResponseAlternative4 | QueryResponseAlternative5 | QueryResponseAlternative6 | QueryResponseAlternative7 | QueryResponseAlternative8 | QueryResponseAlternative9 | QueryResponseAlternative10 | QueryResponseAlternative11 | QueryResponseAlternative12 | QueryResponseAlternative13 | QueryResponseAlternative14 | QueryResponseAlternative15 | QueryResponseAlternative16 | QueryResponseAlternative17 | QueryResponseAlternative18 | QueryResponseAlternative19 | QueryResponseAlternative20 | QueryResponseAlternative21 | QueryResponseAlternative22 | QueryResponseAlternative23 | QueryResponseAlternative24 | QueryResponseAlternative25 | QueryResponseAlternative26 | QueryResponseAlternative27 | QueryResponseAlternative28 | QueryResponseAlternative29 | QueryResponseAlternative30 | QueryResponseAlternative31 | QueryResponseAlternative32 | QueryResponseAlternative33 | QueryResponseAlternative34 | unknown | QueryResponseAlternative35 | QueryResponseAlternative36 | QueryResponseAlternative37 | QueryResponseAlternative38 | QueryResponseAlternative39 | QueryResponseAlternative40 | QueryResponseAlternative41 | QueryResponseAlternative42 | QueryResponseAlternative43 | QueryResponseAlternative44 | QueryResponseAlternative45 | QueryResponseAlternative46 | QueryResponseAlternative47 | QueryResponseAlternative48 | QueryResponseAlternative49 | QueryResponseAlternative50 | QueryResponseAlternative52 | QueryResponseAlternative53 | QueryResponseAlternative54 | QueryResponseAlternative56 | QueryResponseAlternative57 | QueryResponseAlternative58 | QueryResponseAlternative59 | QueryResponseAlternative60 | QueryResponseAlternative61 | QueryResponseAlternative62 | QueryResponseAlternative63 | QueryResponseAlternative64 | QueryResponseAlternative66 | QueryResponseAlternative67 | QueryResponseAlternative68 | QueryResponseAlternative69 | QueryResponseAlternative70 | QueryResponseAlternative71 | QueryResponseAlternative72 | QueryResponseAlternative73 | QueryResponseAlternative74 | QueryResponseAlternative75 | QueryResponseAlternative76 | QueryResponseAlternative77 | QueryResponseAlternative78 | QueryResponseAlternative79 | QueryResponseAlternative80 | QueryResponseAlternative81 | QueryResponseAlternative84 | QueryResponseAlternative85 | QueryResponseAlternative86 | QueryResponseAlternative87 | QueryResponseAlternative88 | QueryResponseAlternative89 | QueryResponseAlternative90 | QueryResponseAlternative91 | QueryResponseAlternative92 | QueryResponseAlternative93 | QueryResponseAlternative94 | QueryResponseAlternative95 | QueryResponseAlternative96 | QueryResponseAlternative97 | QueryResponseAlternative98 | QueryResponseAlternative99 | QueryResponseAlternative100 | QueryResponseAlternative101 | QueryResponseAlternative102 | QueryResponseAlternative103 | QueryResponseAlternative104 | QueryResponseAlternative105 | QueryResponseAlternative106 | QueryResponseAlternative107;
export interface QueryStatusResponse {
query_status: QueryStatus;