Skip to content

Commit

Permalink
fix(trends): more hogql features (#21176)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Mar 27, 2024
1 parent 8d55545 commit 17dd12e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion posthog/hogql_queries/hogql_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def to_actors_query(self) -> ast.SelectQuery:
def calculate(self) -> HogQLQueryResponse:
query = self.to_query()
paginator = None
if not query.limit:
if isinstance(query, ast.SelectQuery) and not query.limit:
paginator = HogQLHasMorePaginator.from_limit_context(limit_context=self.limit_context)
func = cast(
Callable[..., HogQLQueryResponse],
Expand Down
1 change: 1 addition & 0 deletions posthog/hogql_queries/insights/trends/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ def _get_cumulative_query(self, inner_query: ast.SelectQuery, breakdown_enabled:
),
],
select_from=ast.JoinExpr(table=inner_query),
order_by=[ast.OrderExpr(expr=ast.Field(chain=["day_start"]), order="ASC")],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3589,7 +3589,8 @@
breakdown_value)
GROUP BY day_start,
breakdown_value
ORDER BY day_start ASC, breakdown_value ASC))
ORDER BY day_start ASC, breakdown_value ASC)
ORDER BY day_start ASC)
GROUP BY breakdown_value
ORDER BY sum(count) DESC, breakdown_value ASC
LIMIT 10000 SETTINGS readonly=2,
Expand Down Expand Up @@ -3653,7 +3654,8 @@
breakdown_value)
GROUP BY day_start,
breakdown_value
ORDER BY day_start ASC, breakdown_value ASC))
ORDER BY day_start ASC, breakdown_value ASC)
ORDER BY day_start ASC)
GROUP BY breakdown_value
ORDER BY sum(count) DESC, breakdown_value ASC
LIMIT 10000 SETTINGS readonly=2,
Expand Down Expand Up @@ -4036,7 +4038,8 @@
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-30 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-06 23:59:59', 6, 'UTC'))), equals(e.event, 'viewed video'), ifNull(notEquals(nullIf(nullIf(e.`$group_0`, ''), 'null'), ''), 1), notEquals(e.`$group_0`, ''))
GROUP BY e.`$group_0`)
GROUP BY day_start
ORDER BY day_start ASC))
ORDER BY day_start ASC)
ORDER BY day_start ASC)
ORDER BY sum(count) DESC
LIMIT 10000 SETTINGS readonly=2,
max_execution_time=60,
Expand Down Expand Up @@ -4066,7 +4069,8 @@
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'))
GROUP BY day_start)
GROUP BY day_start
ORDER BY day_start ASC))
ORDER BY day_start ASC)
ORDER BY day_start ASC)
ORDER BY sum(count) DESC
LIMIT 10000 SETTINGS readonly=2,
max_execution_time=60,
Expand Down Expand Up @@ -4103,7 +4107,8 @@
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'))
GROUP BY e__pdi.person_id)
GROUP BY day_start
ORDER BY day_start ASC))
ORDER BY day_start ASC)
ORDER BY day_start ASC)
ORDER BY sum(count) DESC
LIMIT 10000 SETTINGS readonly=2,
max_execution_time=60,
Expand Down

0 comments on commit 17dd12e

Please sign in to comment.