Skip to content

Commit

Permalink
Update query snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 26, 2024
1 parent a810673 commit bc675e7
Show file tree
Hide file tree
Showing 7 changed files with 6,156 additions and 2,884 deletions.
4,452 changes: 2,933 additions & 1,519 deletions posthog/queries/test/__snapshots__/test_trends.ambr

Large diffs are not rendered by default.

476 changes: 392 additions & 84 deletions posthog/queries/trends/test/__snapshots__/test_breakdowns.ambr

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# ---
# name: TestBreakdownsByCurrentURL.test_breakdown_by_current_url.1
'''

SELECT groupArray(day_start) as date,
groupArray(count) AS total,
breakdown_value
Expand All @@ -30,13 +29,36 @@
FROM
(SELECT *
FROM
(SELECT toUInt16(0) AS total,
ticks.day_start as day_start,
breakdown_value
(-- Create a table with 1 row for each interval for the requested date range
-- This acts as a method of zero filling, i.e. when there are no data points
-- for a given interval, we'll still have a row for the group by interval with
-- a 0 value.
--
-- It's essentially a cross product of graph "ticks" and breakdown values.
--
-- TODO: we're relying on num_intervals, seconds_int_interval etc. being passed
-- in as a parameter. To reduce the coupling between here and the
-- calling code, we could perform calculations for these within the query
-- itself based on date_to/date_from. We could also pass in the intervals
-- explicitly, although we'll be relying on the date handling between python
-- and ClickHouse to be the same.
--
-- NOTE: there is the ORDER BY ... WITH FILL Expression but I'm not sure how we'd
-- handle the edge cases:
--
-- https://clickhouse.com/docs/en/sql-reference/statements/select/order-by/#orderby-with-fill
--
SELECT toUInt16(0) AS total,
ticks.day_start as day_start,
breakdown_value
FROM
(SELECT toStartOfDay(toDateTime('2020-01-12 23:59:59', 'UTC')) - toIntervalDay(number) as day_start
(-- Generates all the intervals/ticks in the date range
-- NOTE: we build this range by including successive intervals back from the
-- upper bound, then including the lower bound in the query also.
SELECT toStartOfDay(toDateTime('2020-01-12 23:59:59', 'UTC')) - toIntervalDay(number) as day_start
FROM numbers(11)
UNION ALL SELECT toStartOfDay(toDateTime('2020-01-02 00:00:00', 'UTC')) as day_start) as ticks
UNION ALL SELECT toStartOfDay(toDateTime('2020-01-02 00:00:00', 'UTC')) as day_start) as ticks -- Zero fill for all values for the specified breakdown

CROSS JOIN
(SELECT breakdown_value
FROM
Expand Down Expand Up @@ -84,7 +106,6 @@
# ---
# name: TestBreakdownsByCurrentURL.test_breakdown_by_pathname.1
'''

SELECT groupArray(day_start) as date,
groupArray(count) AS total,
breakdown_value
Expand All @@ -95,13 +116,36 @@
FROM
(SELECT *
FROM
(SELECT toUInt16(0) AS total,
ticks.day_start as day_start,
breakdown_value
(-- Create a table with 1 row for each interval for the requested date range
-- This acts as a method of zero filling, i.e. when there are no data points
-- for a given interval, we'll still have a row for the group by interval with
-- a 0 value.
--
-- It's essentially a cross product of graph "ticks" and breakdown values.
--
-- TODO: we're relying on num_intervals, seconds_int_interval etc. being passed
-- in as a parameter. To reduce the coupling between here and the
-- calling code, we could perform calculations for these within the query
-- itself based on date_to/date_from. We could also pass in the intervals
-- explicitly, although we'll be relying on the date handling between python
-- and ClickHouse to be the same.
--
-- NOTE: there is the ORDER BY ... WITH FILL Expression but I'm not sure how we'd
-- handle the edge cases:
--
-- https://clickhouse.com/docs/en/sql-reference/statements/select/order-by/#orderby-with-fill
--
SELECT toUInt16(0) AS total,
ticks.day_start as day_start,
breakdown_value
FROM
(SELECT toStartOfDay(toDateTime('2020-01-12 23:59:59', 'UTC')) - toIntervalDay(number) as day_start
(-- Generates all the intervals/ticks in the date range
-- NOTE: we build this range by including successive intervals back from the
-- upper bound, then including the lower bound in the query also.
SELECT toStartOfDay(toDateTime('2020-01-12 23:59:59', 'UTC')) - toIntervalDay(number) as day_start
FROM numbers(11)
UNION ALL SELECT toStartOfDay(toDateTime('2020-01-02 00:00:00', 'UTC')) as day_start) as ticks
UNION ALL SELECT toStartOfDay(toDateTime('2020-01-02 00:00:00', 'UTC')) as day_start) as ticks -- Zero fill for all values for the specified breakdown

CROSS JOIN
(SELECT breakdown_value
FROM
Expand Down
Loading

0 comments on commit bc675e7

Please sign in to comment.