Skip to content

Commit

Permalink
source id generalization
Browse files Browse the repository at this point in the history
  • Loading branch information
aspicer committed Jun 22, 2024
1 parent 324ea5a commit 08e77ec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 409 deletions.
2 changes: 1 addition & 1 deletion posthog/hogql/test/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_visit_hogqlx_tag_source(self):
"(SELECT id, properties.email AS email FROM "
"(SELECT DISTINCT person_id FROM events) "
"AS source INNER JOIN "
"persons ON equals(persons.id, source.person_id) ORDER BY id ASC) "
"filterable_persons ON equals(filterable_persons.id, source.person_id) ORDER BY id ASC) "
f"LIMIT {MAX_SELECT_RETURNED_ROWS}"
)

Expand Down
2 changes: 1 addition & 1 deletion posthog/hogql_queries/actors_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def to_query(self) -> ast.SelectQuery:
NonSerializableTags.FILTERABLE_PERSONS.value: ast.CompareOperation(
left=ast.Field(chain=["id"]),
right=ast.SelectQuery(
select=[ast.Field(chain=[source_alias, "actor_id"])],
select=[ast.Field(chain=[source_alias, *self.source_id_column(source_query)])],
select_from=ast.JoinExpr(table=source_query, alias=source_alias),
),
op=ast.CompareOperationOp.In,
Expand Down
7 changes: 3 additions & 4 deletions posthog/hogql_queries/insights/stickiness_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ def to_actors_query(self, interval_num: Optional[int] = None) -> ast.SelectQuery
for series in self.series:
events_query = self._events_query(series)
aggregation_alias = "actor_id"
# if series.series.math == "hogql" and series.series.math_hogql is not None:
# aggregation_alias = "actor_id"
# elif series.series.math == "unique_group" and series.series.math_group_type_index is not None:
if series.series.math == "unique_group" and series.series.math_group_type_index is not None:
if series.series.math == "hogql" and series.series.math_hogql is not None:
aggregation_alias = "actor_id"
elif series.series.math == "unique_group" and series.series.math_group_type_index is not None:
aggregation_alias = "group_key"
events_query.select = [ast.Alias(alias=aggregation_alias, expr=ast.Field(chain=["aggregation_target"]))]
events_query.group_by = None
Expand Down
Loading

0 comments on commit 08e77ec

Please sign in to comment.