Skip to content

Commit

Permalink
Added aliases for groups from group mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert09 committed Oct 12, 2023
1 parent f8512f1 commit 0846c4d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions posthog/hogql/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from posthog.hogql.database.schema.session_replay_events import RawSessionReplayEventsTable, SessionReplayEventsTable
from posthog.hogql.database.schema.static_cohort_people import StaticCohortPeople
from posthog.hogql.errors import HogQLException
from posthog.models.group_type_mapping import GroupTypeMapping
from posthog.models.team.team import WeekStartDay
from posthog.utils import PersonOnEventsMode

Expand Down Expand Up @@ -118,6 +119,9 @@ def create_hogql_database(team_id: int) -> Database:
database.events.fields["person"] = FieldTraverser(chain=["poe"])
database.events.fields["person_id"] = StringDatabaseField(name="person_id")

for mapping in GroupTypeMapping.objects.filter(team=team):
database.events.fields[mapping.group_type] = FieldTraverser(chain=[f"group_{mapping.group_type_index}"])

for view in DataWarehouseViewLink.objects.filter(team_id=team.pk).exclude(deleted=True):
table = database.get_table(view.table)

Expand Down

0 comments on commit 0846c4d

Please sign in to comment.