Skip to content

Commit

Permalink
test actors
Browse files Browse the repository at this point in the history
  • Loading branch information
aspicer committed Jun 24, 2024
1 parent 81351ca commit 5ec2768
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions posthog/hogql/database/schema/persons.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,23 @@ class FilterablePersonsTable(LazyTable):
@staticmethod
def is_promotable_expr(expr):
return (
isinstance(expr, CompareOperation) and expr.op == CompareOperationOp.In and expr.left == Field(chain=["id"])
isinstance(expr, CompareOperation)
and expr.op == CompareOperationOp.In
and expr.left == Field(chain=["filterable_persons", "id"])
)

@staticmethod
def partition_exprs(exprs):
not_promotable = []
promotable = []
[
promotable.append(expr) if FilterablePersonsTable.is_promotable_expr(expr) else not_promotable.append(expr)
for expr in exprs
]
for expr in exprs:
if FilterablePersonsTable.is_promotable_expr(expr):
# Erase "filterable_persons" from the chain before bringing inside
expr.left = Field(chain=["id"])
promotable.append(expr)
else:
not_promotable.append(expr)

return promotable, not_promotable

def lazy_select(self, table_to_add: LazyTableToAdd, context, node):
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 @@ -275,7 +275,7 @@ def to_query(self) -> ast.SelectQuery:
right=ast.Field(chain=[source_alias, *source_id_chain]),
),
ast.CompareOperation(
left=ast.Field(chain=["id"]),
left=ast.Field(chain=[origin, "id"]),
right=ast.SelectQuery(
select=[ast.Field(chain=[source_alias, *self.source_id_column(source_query)])],
select_from=ast.JoinExpr(table=source_query, alias=source_alias),
Expand Down

0 comments on commit 5ec2768

Please sign in to comment.