From e3439c0c3e48514915d8e2cc85858b299802e389 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Mon, 4 Dec 2023 17:23:40 +0100 Subject: [PATCH] fixes --- posthog/api/cohort.py | 2 +- posthog/hogql/hogql.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/posthog/api/cohort.py b/posthog/api/cohort.py index 2706799865fd8..f7cbf1fd3b71b 100644 --- a/posthog/api/cohort.py +++ b/posthog/api/cohort.py @@ -155,7 +155,7 @@ def create(self, validated_data: Dict, *args: Any, **kwargs: Any) -> Cohort: if not validated_data.get("is_static"): validated_data["is_calculating"] = True if validated_data.get("query") and validated_data.get("filters"): - raise ValidationError("Cannot set both query and filters") + raise ValidationError("Cannot set both query and filters at the same time.") cohort = Cohort.objects.create(team_id=self.context["team_id"], **validated_data) diff --git a/posthog/hogql/hogql.py b/posthog/hogql/hogql.py index 608dd9a7b62c9..cf3cdc2949392 100644 --- a/posthog/hogql/hogql.py +++ b/posthog/hogql/hogql.py @@ -15,7 +15,7 @@ # This is called only from "non-hogql-based" insights to translate HogQL expressions into ClickHouse SQL # All the constant string values will be collected into context.values def translate_hogql( - query: str | ast.Expr, + query: str, context: HogQLContext, dialect: Literal["hogql", "clickhouse"] = "clickhouse", table: str = "events", @@ -33,11 +33,7 @@ def translate_hogql( if context.team_id is None: raise ValueError("Cannot translate HogQL for a filter with no team specified") context.database = create_hogql_database(context.team_id) - - if isinstance(query, str): - node = parse_expr(query, placeholders=placeholders) - else: - node = query + node = parse_expr(query, placeholders=placeholders) select_query = ast.SelectQuery(select=[node], select_from=ast.JoinExpr(table=ast.Field(chain=[table]))) if events_table_alias is not None: