Skip to content

Commit

Permalink
do distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Apr 16, 2024
1 parent e850639 commit 8148b11
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions posthog/hogql/database/schema/cohort_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,14 @@ def select_from_cohort_people_table(requested_fields: Dict[str, List[str | int]]

return ast.SelectQuery(
select=fields,
distinct=True,
select_from=ast.JoinExpr(table=ast.Field(chain=[table_name])),
where=ast.And(
exprs=[
ast.CompareOperation(
op=ast.CompareOperationOp.In,
left=ast.Tuple(
exprs=[ast.Field(chain=[table_name, "cohort_id"]), ast.Field(chain=[table_name, "version"])]
),
right=ast.Constant(value=cohort_tuples),
),
ast.CompareOperation(
op=ast.CompareOperationOp.Gt,
left=ast.Field(chain=[table_name, "sign"]),
right=ast.Constant(value=0),
),
]
where=ast.CompareOperation(
op=ast.CompareOperationOp.In,
left=ast.Tuple(
exprs=[ast.Field(chain=[table_name, "cohort_id"]), ast.Field(chain=[table_name, "version"])]
),
right=ast.Constant(value=cohort_tuples),
),
)

Expand Down

0 comments on commit 8148b11

Please sign in to comment.