Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hogql): Bring back cohort filter support in actors query #22462

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 21 additions & 18 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@
"additionalProperties": false,
"properties": {
"fixedProperties": {
"description": "Currently only person filters supported (including via HogQL), See `filter_conditions()` in actor_strategies.py.",
"description": "Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
"items": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
}
]
"$ref": "#/definitions/AnyPersonScopeFilter"
},
"type": "array"
},
Expand All @@ -89,16 +82,9 @@
"type": "array"
},
"properties": {
"description": "Currently only person filters supported (including via HogQL). see `filter_conditions()` in actor_strategies.py.",
"description": "Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
"items": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
}
]
"$ref": "#/definitions/AnyPersonScopeFilter"
},
"type": "array"
},
Expand Down Expand Up @@ -255,6 +241,23 @@
}
]
},
"AnyPersonScopeFilter": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/CohortPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
},
{
"$ref": "#/definitions/EmptyPropertyFilter"
}
],
"description": "Any filter type supported by `property_to_expr(scope=\"person\", ...)`."
},
"AnyPropertyFilter": {
"anyOf": [
{
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AnyPersonScopeFilter,
AnyPropertyFilter,
BaseMathType,
Breakdown,
Expand All @@ -13,7 +14,6 @@ import {
FunnelsFilterType,
GroupMathType,
HogQLMathType,
HogQLPropertyFilter,
InsightShortId,
InsightType,
IntervalType,
Expand Down Expand Up @@ -990,10 +990,10 @@ export interface ActorsQuery extends DataNode<ActorsQueryResponse> {
source?: InsightActorsQuery | FunnelsActorsQuery | FunnelCorrelationActorsQuery | HogQLQuery
select?: HogQLExpression[]
search?: string
/** Currently only person filters supported (including via HogQL). see `filter_conditions()` in actor_strategies.py. */
properties?: (PersonPropertyFilter | HogQLPropertyFilter)[]
/** Currently only person filters supported (including via HogQL), See `filter_conditions()` in actor_strategies.py. */
fixedProperties?: (PersonPropertyFilter | HogQLPropertyFilter)[]
/** Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py. */
properties?: AnyPersonScopeFilter[]
/** Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py. */
fixedProperties?: AnyPersonScopeFilter[]
orderBy?: string[]
limit?: integer
offset?: integer
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,13 @@ export type AnyPropertyFilter =
| DataWarehousePropertyFilter
| DataWarehousePersonPropertyFilter

/** Any filter type supported by `property_to_expr(scope="person", ...)`. */
export type AnyPersonScopeFilter =
| PersonPropertyFilter
| CohortPropertyFilter
| HogQLPropertyFilter
| EmptyPropertyFilter

export type AnyFilterLike = AnyPropertyFilter | PropertyGroupFilter | PropertyGroupFilterValue

export type SessionRecordingId = SessionRecordingType['id']
Expand Down
12 changes: 8 additions & 4 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4134,9 +4134,11 @@ class ActorsQuery(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
fixedProperties: Optional[list[Union[PersonPropertyFilter, HogQLPropertyFilter]]] = Field(
fixedProperties: Optional[
list[Union[PersonPropertyFilter, CohortPropertyFilter, HogQLPropertyFilter, EmptyPropertyFilter]]
] = Field(
default=None,
description="Currently only person filters supported (including via HogQL), See `filter_conditions()` in actor_strategies.py.",
description="Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
)
kind: Literal["ActorsQuery"] = "ActorsQuery"
limit: Optional[int] = None
Expand All @@ -4145,9 +4147,11 @@ class ActorsQuery(BaseModel):
)
offset: Optional[int] = None
orderBy: Optional[list[str]] = None
properties: Optional[list[Union[PersonPropertyFilter, HogQLPropertyFilter]]] = Field(
properties: Optional[
list[Union[PersonPropertyFilter, CohortPropertyFilter, HogQLPropertyFilter, EmptyPropertyFilter]]
] = Field(
default=None,
description="Currently only person filters supported (including via HogQL). see `filter_conditions()` in actor_strategies.py.",
description="Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
)
response: Optional[ActorsQueryResponse] = None
search: Optional[str] = None
Expand Down
Loading