Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aspicer committed Dec 5, 2024
1 parent 092f7cc commit bb88e07
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
28 changes: 27 additions & 1 deletion posthog/hogql_queries/actors_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,35 @@ def to_query(self) -> ast.SelectQuery:
else:
assert self.source_query_runner is not None # For type checking
source_query = self.source_query_runner.to_actors_query()
if isinstance(source_query, ast.SelectQuery): # typing fun
if isinstance(source_query, ast.SelectQuery): #: # typing fun
source_query.select.append(parse_expr("actor_id as id"))
source_query.order_by = order_by
return source_query
source_query = self.source_query_runner.to_actors_query()

source_id_chain = self.source_id_column(source_query)
source_alias = "source"

origin = self.strategy.origin

join_on: ast.Expr = ast.CompareOperation(
op=ast.CompareOperationOp.Eq,
left=ast.Field(chain=[origin, self.strategy.origin_id]),
right=ast.Field(chain=[source_alias, *source_id_chain]),
)

join_expr = ast.JoinExpr(
table=source_query,
alias=source_alias,
next_join=ast.JoinExpr(
table=ast.Field(chain=[origin]),
join_type="INNER JOIN",
constraint=ast.JoinConstraint(
expr=join_on,
constraint_type="ON",
),
),
)

return ast.SelectQuery(
select=columns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4347,7 +4347,7 @@ def test_recording(self):
)

self.assertCountEqual([p1.uuid, p2.uuid], [row[0]["id"] for row in results])
matched_recordings = [list(row[3]) for row in results]
matched_recordings = [list(row[1]) for row in results]

self.assertCountEqual(
[
Expand Down Expand Up @@ -4429,7 +4429,7 @@ def test_recording_with_no_window_or_session_id(self):
)

self.assertEqual([p1.uuid], [row[0]["id"] for row in results])
self.assertEqual([[]], [list(row[3]) for row in results])
self.assertEqual([[]], [list(row[1]) for row in results])

@snapshot_clickhouse_queries
@freeze_time("2012-01-01T03:21:34.000Z")
Expand Down Expand Up @@ -4532,7 +4532,7 @@ def test_recording_with_start_and_end(self):
}
]
],
[list(row[3]) for row in results],
[list(row[1]) for row in results],
)

@snapshot_clickhouse_queries
Expand Down Expand Up @@ -4664,7 +4664,7 @@ def test_recording_for_dropoff(self):
}
]
],
[list(row[3]) for row in results],
[list(row[1]) for row in results],
)

@skip("TODO: Funnels")
Expand Down

0 comments on commit bb88e07

Please sign in to comment.