diff --git a/posthog/hogql/database/database.py b/posthog/hogql/database/database.py index 18dee90dd1928..f0367da08ff9b 100644 --- a/posthog/hogql/database/database.py +++ b/posthog/hogql/database/database.py @@ -161,6 +161,7 @@ def create_hogql_database(team_id: int, modifiers: Optional[HogQLQueryModifiers] name="person_id", expr=parse_expr("ifNull(override.override_person_id, event_person_id)", start=None), ) + database.events.fields["poe"].fields["id"] = database.events.fields["person_id"] database.events.fields["person"] = FieldTraverser(chain=["poe"]) for mapping in GroupTypeMapping.objects.filter(team=team): diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.py index 8fa6606732bb3..0f254a1ed39b8 100644 --- a/posthog/hogql/resolver.py +++ b/posthog/hogql/resolver.py @@ -461,7 +461,6 @@ def visit_field(self, node: ast.Field): node.type = loop_type if isinstance(node.type, ast.ExpressionFieldType): - # TODO: make sure new_expr is of type node.type.return_type new_expr = clone_expr(node.type.expr) new_node = ast.Alias(alias=node.type.name, expr=new_expr, hidden=True) new_node = self.visit(new_node) diff --git a/posthog/hogql/test/test_modifiers.py b/posthog/hogql/test/test_modifiers.py index 028f9dd455216..744ad4f063fdb 100644 --- a/posthog/hogql/test/test_modifiers.py +++ b/posthog/hogql/test/test_modifiers.py @@ -70,7 +70,7 @@ def test_modifiers_persons_on_events_mode_mapping(self): ( PersonsOnEventsMode.v2_enabled, "events.event", - "events.person_id", + "ifNull(events__override.override_person_id, events.person_id) AS id", "events.person_properties", "toTimeZone(events.person_created_at, %(hogql_val_0)s) AS created_at", ),