0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
posthog/ee/clickhouse/queries/event_query.py
Eric Duong e61b23cbcc
refactor: move retention query class from /ee to /posthog (#10137)
* refactor: move files and change insight class

* move sql

* types

* fix imports

* refactor: propogate class

* change order

* fix: restructure imports

* fix imports

* move tests

* add dependency

* remove deprecated

* inherit foss tests

* refactor: split stickiness /posthog and /ee (#10085)

* refactor: move files

* refactor: variable naming

* factory pattern

* fix: restore exceptions hog

* remove factory pattern

* fix imports

* fix import

* Update snapshots

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-06-07 12:52:45 -04:00

55 lines
2.3 KiB
Python

from typing import Dict, List, Optional, Tuple, Union
from ee.clickhouse.materialized_columns.columns import ColumnName
from ee.clickhouse.queries.column_optimizer import EnterpriseColumnOptimizer
from ee.clickhouse.queries.groups_join_query import GroupsJoinQuery
from posthog.models.filters.filter import Filter
from posthog.models.filters.path_filter import PathFilter
from posthog.models.filters.retention_filter import RetentionFilter
from posthog.models.filters.session_recordings_filter import SessionRecordingsFilter
from posthog.models.filters.stickiness_filter import StickinessFilter
from posthog.models.property import PropertyName
from posthog.models.team import Team
from posthog.queries.event_query.event_query import EventQuery
class EnterpriseEventQuery(EventQuery):
_column_optimizer: EnterpriseColumnOptimizer
def __init__(
self,
filter: Union[Filter, PathFilter, RetentionFilter, StickinessFilter, SessionRecordingsFilter],
team: Team,
round_interval=False,
should_join_distinct_ids=False,
should_join_persons=False,
# Extra events/person table columns to fetch since parent query needs them
extra_fields: List[ColumnName] = [],
extra_event_properties: List[PropertyName] = [],
extra_person_fields: List[ColumnName] = [],
override_aggregate_users_by_distinct_id: Optional[bool] = None,
using_person_on_events: bool = False,
**kwargs,
) -> None:
super().__init__(
filter=filter,
team=team,
round_interval=round_interval,
should_join_distinct_ids=should_join_distinct_ids,
should_join_persons=should_join_persons,
extra_fields=extra_fields,
extra_event_properties=extra_event_properties,
extra_person_fields=extra_person_fields,
override_aggregate_users_by_distinct_id=override_aggregate_users_by_distinct_id,
using_person_on_events=using_person_on_events,
**kwargs,
)
self._column_optimizer = EnterpriseColumnOptimizer(self._filter, self._team_id)
def _get_groups_query(self) -> Tuple[str, Dict]:
return GroupsJoinQuery(
self._filter, self._team_id, self._column_optimizer, using_person_on_events=self._using_person_on_events
).get_join_query()