diff --git a/package.json b/package.json index 743d7a30ca4dc..7b7a450e679da 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "pmtiles": "^2.11.0", "postcss": "^8.4.31", "postcss-preset-env": "^9.3.0", - "posthog-js": "1.139.2", + "posthog-js": "1.139.3", "posthog-js-lite": "3.0.0", "prettier": "^2.8.8", "prop-types": "^15.7.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18a35a0a62ff4..45bdf07dd9d4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -260,8 +260,8 @@ dependencies: specifier: ^9.3.0 version: 9.3.0(postcss@8.4.31) posthog-js: - specifier: 1.139.2 - version: 1.139.2 + specifier: 1.139.3 + version: 1.139.3 posthog-js-lite: specifier: 3.0.0 version: 3.0.0 @@ -17706,8 +17706,8 @@ packages: resolution: {integrity: sha512-dyajjnfzZD1tht4N7p7iwf7nBnR1MjVaVu+MKr+7gBgA39bn28wizCIJZztZPtHy4PY0YwtSGgwfBCuG/hnHgA==} dev: false - /posthog-js@1.139.2: - resolution: {integrity: sha512-myyuOADqZvYwgqmriwlKDEUDwLhscivFLh67UWBj4Wt9kOlmklvJb36W0ES2GAS6IdojbnGZGH5lF3heqreLWQ==} + /posthog-js@1.139.3: + resolution: {integrity: sha512-NmPtOAXogxT/QSmeVCQJeIemBn8rEGfFPIXOynYKgXfntrw0KhzGXXvRXGLVjl5Zx6Nslf5NlmMnzmq1wjLZIA==} dependencies: fflate: 0.4.8 preact: 10.22.0 diff --git a/posthog/hogql_queries/insights/trends/aggregation_operations.py b/posthog/hogql_queries/insights/trends/aggregation_operations.py index 075599cb9beec..f013d65b6f054 100644 --- a/posthog/hogql_queries/insights/trends/aggregation_operations.py +++ b/posthog/hogql_queries/insights/trends/aggregation_operations.py @@ -5,7 +5,6 @@ from posthog.hogql_queries.utils.query_date_range import QueryDateRange from posthog.models.team.team import Team from posthog.schema import BaseMathType, ChartDisplayType, EventsNode, ActionsNode, DataWarehouseNode -from posthog.models.filters.mixins.utils import cached_property from posthog.hogql_queries.insights.data_warehouse_mixin import DataWarehouseInsightQueryMixin @@ -71,18 +70,11 @@ def __init__( self.query_date_range = query_date_range self.is_total_value = is_total_value - @cached_property - def _id_field(self) -> ast.Expr: - if isinstance(self.series, DataWarehouseNode): - return ast.Field(chain=["e", self.series.id_field]) - - return ast.Field(chain=["e", "uuid"]) - def select_aggregation(self) -> ast.Expr: if self.series.math == "hogql" and self.series.math_hogql is not None: return parse_expr(self.series.math_hogql) elif self.series.math == "total": - return parse_expr("count({id_field})", placeholders={"id_field": self._id_field}) + return parse_expr("count()") elif self.series.math == "dau": actor = "e.distinct_id" if self.team.aggregate_users_by_distinct_id else "e.person_id" return parse_expr(f"count(DISTINCT {actor})") @@ -112,9 +104,7 @@ def select_aggregation(self) -> ast.Expr: elif self.series.math == "p99": return self._math_quantile(0.99, None) - return parse_expr( - "count({id_field})", placeholders={"id_field": self._id_field} - ) # All "count per actor" get replaced during query orchestration + return parse_expr("count()") # All "count per actor" get replaced during query orchestration def actor_id(self) -> ast.Expr: if self.series.math == "unique_group" and self.series.math_group_type_index is not None: @@ -367,7 +357,7 @@ def _events_query( ( """ SELECT - count({id_field}) AS total + count() AS total FROM {table} AS e WHERE {events_where_clause} GROUP BY {person_field} @@ -375,7 +365,7 @@ def _events_query( if isinstance(self.series, DataWarehouseNode) else """ SELECT - count({id_field}) AS total + count() AS total FROM events AS e SAMPLE {sample} WHERE {events_where_clause} @@ -383,7 +373,6 @@ def _events_query( """ ), placeholders={ - "id_field": self._id_field, "table": self._table_expr, "events_where_clause": where_clause_combined, "sample": sample_value, diff --git a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr index 02c5905fc6118..8d5b1251b1d31 100644 --- a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr +++ b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr @@ -58,7 +58,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -156,7 +156,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 LEFT OUTER JOIN @@ -200,7 +200,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(e__group_0.properties___industry), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -310,7 +310,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(e__group_0.properties___industry), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -359,7 +359,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -400,7 +400,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -649,7 +649,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -892,7 +892,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -977,7 +977,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-26 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-02 23:59:59', 6, 'UTC'))), equals(e.event, 'event_name'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'name'), ''), 'null'), '^"|"$', ''), 'Jane'), 0)) @@ -1004,7 +1004,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 LEFT JOIN @@ -1116,7 +1116,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 LEFT JOIN @@ -1291,7 +1291,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'US/Pacific'), 0) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'US/Pacific'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2022-10-31 00:00:00', 6, 'US/Pacific')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'US/Pacific'), assumeNotNull(parseDateTime64BestEffortOrNull('2022-11-30 23:59:59', 6, 'US/Pacific'))), equals(e.event, 'sign up')) @@ -1345,7 +1345,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -1416,7 +1416,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -1460,7 +1460,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -1505,7 +1505,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -1550,7 +1550,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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, 'watched movie'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'name'), ''), 'null'), '^"|"$', ''), '1'), 0)) @@ -1577,7 +1577,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -1622,7 +1622,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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, 'watched movie'), ifNull(equals(nullIf(nullIf(e.mat_name, ''), 'null'), '1'), 0)) @@ -1649,7 +1649,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -1703,7 +1703,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-03 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-03 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -1893,7 +1893,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-29 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -2001,7 +2001,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-29 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -2076,7 +2076,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'America/Phoenix')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-29 00:00:00', 6, 'America/Phoenix')))), lessOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'America/Phoenix'))), equals(e.event, 'sign up')) @@ -2184,7 +2184,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'America/Phoenix')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-29 00:00:00', 6, 'America/Phoenix')))), lessOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'America/Phoenix'))), equals(e.event, 'sign up')) @@ -2259,7 +2259,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'Asia/Tokyo')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-29 00:00:00', 6, 'Asia/Tokyo')))), lessOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'Asia/Tokyo'))), equals(e.event, 'sign up')) @@ -2367,7 +2367,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'Asia/Tokyo')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-29 00:00:00', 6, 'Asia/Tokyo')))), lessOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'Asia/Tokyo'))), equals(e.event, 'sign up')) @@ -2476,7 +2476,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfHour(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 00:00:00', 6, 'UTC'))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 10:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -2537,7 +2537,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfHour(toTimeZone(e.timestamp, 'America/Phoenix')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 00:00:00', 6, 'America/Phoenix'))), lessOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 10:59:59', 6, 'America/Phoenix'))), equals(e.event, 'sign up')) @@ -2598,7 +2598,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfHour(toTimeZone(e.timestamp, 'Asia/Tokyo')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 00:00:00', 6, 'Asia/Tokyo'))), lessOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 10:59:59', 6, 'Asia/Tokyo'))), equals(e.event, 'sign up')) @@ -2625,7 +2625,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'UTC'), 0) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-26 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -2652,7 +2652,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'UTC'), 3) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 00:00:00', 6, 'UTC')), 3)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-26 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -2679,7 +2679,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'America/Phoenix'), 0) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 00:00:00', 6, 'America/Phoenix')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-26 23:59:59', 6, 'America/Phoenix'))), equals(e.event, 'sign up')) @@ -2706,7 +2706,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'America/Phoenix'), 3) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 00:00:00', 6, 'America/Phoenix')), 3)), lessOrEquals(toTimeZone(e.timestamp, 'America/Phoenix'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-26 23:59:59', 6, 'America/Phoenix'))), equals(e.event, 'sign up')) @@ -2733,7 +2733,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'Asia/Tokyo'), 0) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 00:00:00', 6, 'Asia/Tokyo')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-26 23:59:59', 6, 'Asia/Tokyo'))), equals(e.event, 'sign up')) @@ -2760,7 +2760,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfWeek(toTimeZone(e.timestamp, 'Asia/Tokyo'), 3) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 00:00:00', 6, 'Asia/Tokyo')), 3)), lessOrEquals(toTimeZone(e.timestamp, 'Asia/Tokyo'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-26 23:59:59', 6, 'Asia/Tokyo'))), equals(e.event, 'sign up')) @@ -2794,7 +2794,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(e__pdi__person.properties___email), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -2855,7 +2855,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(toString(e__pdi__person.properties___email), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1 @@ -3161,7 +3161,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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')))) @@ -3188,7 +3188,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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')) @@ -3463,7 +3463,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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')) @@ -3490,7 +3490,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-21 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')) @@ -3517,7 +3517,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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')) @@ -3541,7 +3541,7 @@ FROM (SELECT avg(total) AS total FROM - (SELECT count(e.uuid) AS total + (SELECT count() AS total FROM events AS e SAMPLE 1 INNER JOIN (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, @@ -3568,7 +3568,7 @@ FROM (SELECT avg(total) AS total FROM - (SELECT count(e.uuid) AS total + (SELECT count() AS total FROM events AS e SAMPLE 1 LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, @@ -3605,7 +3605,7 @@ (SELECT avg(total) AS total, breakdown_value AS breakdown_value FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, ifNull(nullIf(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '')), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM events AS e SAMPLE 1.0 INNER JOIN @@ -3648,7 +3648,7 @@ (SELECT avg(total) AS total, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 INNER JOIN @@ -3690,7 +3690,7 @@ (SELECT avg(total) AS total, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 LEFT OUTER JOIN @@ -3789,7 +3789,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.uuid) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start FROM events AS e SAMPLE 1 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')) diff --git a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr index 59d0c6f5c2781..206c3eca85c8a 100644 --- a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr +++ b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr @@ -15,7 +15,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.id) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.created, 'UTC')) AS day_start, ifNull(nullIf(toString(e.prop_1), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/*.parquet', 'object_storage_root_user', 'object_storage_root_password', 'Parquet', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS e @@ -56,7 +56,7 @@ day_start AS day_start, breakdown_value AS breakdown_value FROM - (SELECT count(e.id) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.created, 'UTC')) AS day_start, ifNull(nullIf(toString(e.prop_1), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/*.parquet', 'object_storage_root_user', 'object_storage_root_password', 'Parquet', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS e @@ -90,7 +90,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.id) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.created, 'UTC')) AS day_start FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/*.parquet', 'object_storage_root_user', 'object_storage_root_password', 'Parquet', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS e WHERE and(ifNull(greaterOrEquals(toTimeZone(e.created, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2023-01-01 00:00:00', 6, 'UTC')))), 0), ifNull(lessOrEquals(toTimeZone(e.created, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2023-01-07 23:59:59', 6, 'UTC'))), 0)) @@ -117,7 +117,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.id) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.created, 'UTC')) AS day_start FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/*.parquet', 'object_storage_root_user', 'object_storage_root_password', 'Parquet', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS e WHERE and(ifNull(greaterOrEquals(toTimeZone(e.created, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2023-01-01 00:00:00', 6, 'UTC')))), 0), ifNull(lessOrEquals(toTimeZone(e.created, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2023-01-07 23:59:59', 6, 'UTC'))), 0), equals(e.prop_1, 'a')) @@ -144,7 +144,7 @@ (SELECT sum(total) AS count, day_start AS day_start FROM - (SELECT count(e.id) AS total, + (SELECT count() AS total, toStartOfDay(toTimeZone(e.created, 'UTC')) AS day_start FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/*.parquet', 'object_storage_root_user', 'object_storage_root_password', 'Parquet', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS e WHERE and(ifNull(greaterOrEquals(toTimeZone(e.created, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2023-01-01 00:00:00', 6, 'UTC')))), 0), ifNull(lessOrEquals(toTimeZone(e.created, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2023-01-07 23:59:59', 6, 'UTC'))), 0), equals(e.prop_1, 'a'))