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

chore: remove event properties from subquery #24558

Merged
merged 4 commits into from
Aug 27, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
from typing import Any, NamedTuple, cast, Optional, Union
from datetime import datetime, timedelta

Expand All @@ -21,10 +20,6 @@
logger = structlog.get_logger(__name__)


def is_event_property(p: Property) -> bool:
return p.type == "event" or (p.type == "hogql" and bool(re.search(r"(?<!person\.)properties\.", p.key)))


def is_person_property(p: Property) -> bool:
return p.type == "person" or (p.type == "hogql" and "person.properties" in p.key)

Expand Down Expand Up @@ -239,9 +234,7 @@ def _having_predicates(self) -> ast.Expr:
return property_to_expr(self._filter.having_predicates, team=self._team, scope="replay")

def _strip_person_and_event_properties(self, property_group: PropertyGroup) -> PropertyGroup | None:
property_groups_to_keep = [
g for g in property_group.flat if not is_event_property(g) and not is_person_property(g)
]
property_groups_to_keep = [g for g in property_group.flat if not is_person_property(g)]

return (
PropertyGroup(
Expand Down Expand Up @@ -427,7 +420,7 @@ def _select_from_events(self, select_expr: ast.Expr) -> ast.SelectQuery:

def get_query_for_session_id_matching(self) -> ast.SelectQuery | ast.SelectUnionQuery | None:
use_poe = poe_is_active(self._team) and self.person_properties
if self._filter.entities or self.event_properties or use_poe:
if self._filter.entities or use_poe:
return self._select_from_events(ast.Alias(alias="session_id", expr=ast.Field(chain=["$session_id"])))
else:
return None
Expand Down Expand Up @@ -497,9 +490,6 @@ def _where_predicates(self) -> ast.Expr:
if event_where_exprs:
exprs.append(self._filter.events_operand(exprs=event_where_exprs))

if self.event_properties:
exprs.append(property_to_expr(self.event_properties, team=self._team, scope="replay"))

if self._team.person_on_events_mode and self.person_properties:
exprs.append(property_to_expr(self.person_properties, team=self._team, scope="event"))

Expand Down Expand Up @@ -529,10 +519,6 @@ def _having_predicates(self) -> ast.Expr:

return ast.Constant(value=True)

@cached_property
def event_properties(self):
return [g for g in self._filter.property_groups.flat if is_event_property(g)]

@cached_property
def person_properties(self) -> PropertyGroup | None:
person_property_groups = [g for g in self._filter.property_groups.flat if is_person_property(g)]
Expand Down
Loading
Loading