Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Dec 4, 2023
1 parent 6efa324 commit e3439c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion posthog/api/cohort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 2 additions & 6 deletions posthog/hogql/hogql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:
Expand Down

0 comments on commit e3439c0

Please sign in to comment.