|
|
|
@ -187,7 +187,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_by_group_props_person_on_events
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__group_0.properties___industry AS value,
|
|
|
|
|
SELECT toString(e__group_0.properties___industry) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
LEFT JOIN
|
|
|
|
@ -210,7 +210,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -231,7 +231,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(e__group_0.properties___industry, '$$_posthog_breakdown_null_$$'), ['finance', 'technology'], ['finance', 'technology'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__group_0.properties___industry), '$$_posthog_breakdown_null_$$'), ['finance', 'technology'], ['finance', 'technology'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT argMax(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', ''), groups._timestamp) AS properties___industry,
|
|
|
|
@ -241,7 +241,7 @@
|
|
|
|
|
WHERE and(equals(groups.team_id, 2), ifNull(equals(index, 0), 0))
|
|
|
|
|
GROUP BY groups.group_type_index,
|
|
|
|
|
groups.group_key) AS e__group_0 ON equals(e.`$group_0`, e__group_0.key)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(e__group_0.properties___industry, 'finance'), 0), ifNull(equals(e__group_0.properties___industry, 'technology'), 0)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(toString(e__group_0.properties___industry), 'finance'), 0), ifNull(equals(toString(e__group_0.properties___industry), 'technology'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -287,7 +287,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_by_group_props_with_person_filter_person_on_events
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__group_0.properties___industry AS value,
|
|
|
|
|
SELECT toString(e__group_0.properties___industry) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
LEFT JOIN
|
|
|
|
@ -310,7 +310,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -331,7 +331,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(e__group_0.properties___industry, '$$_posthog_breakdown_null_$$'), ['finance'], ['finance'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__group_0.properties___industry), '$$_posthog_breakdown_null_$$'), ['finance'], ['finance'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT argMax(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', ''), groups._timestamp) AS properties___industry,
|
|
|
|
@ -341,7 +341,7 @@
|
|
|
|
|
WHERE and(equals(groups.team_id, 2), ifNull(equals(index, 0), 0))
|
|
|
|
|
GROUP BY groups.group_type_index,
|
|
|
|
|
groups.group_key) AS e__group_0 ON equals(e.`$group_0`, e__group_0.key)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'key'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(e__group_0.properties___industry, 'finance'), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'key'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(toString(e__group_0.properties___industry), 'finance'), 0))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -356,7 +356,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_filtering_with_properties_in_new_format
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC')))), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Windows'), 0)), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0)))
|
|
|
|
@ -371,7 +371,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -392,9 +392,9 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['second url'], ['second url'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['second url'], ['second url'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Windows'), 0)), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'second url'), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Windows'), 0)), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')), 'second url'), 0))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -409,7 +409,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_filtering_with_properties_in_new_format.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC')))), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 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'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Windows'), 0)), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0)))
|
|
|
|
@ -423,24 +423,38 @@
|
|
|
|
|
# name: TestTrends.test_breakdown_filtering_with_properties_in_new_format.3
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start
|
|
|
|
|
day_start AS day_start,
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT 0 AS total,
|
|
|
|
|
minus(toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC'))), toIntervalDay(numbers.number)) AS day_start
|
|
|
|
|
FROM numbers(coalesce(dateDiff('day', assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 00:00:00', 6, 'UTC')), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC'))), 0)) AS numbers
|
|
|
|
|
UNION ALL SELECT 0 AS total,
|
|
|
|
|
toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 00:00:00', 6, 'UTC'))) AS day_start
|
|
|
|
|
ticks.day_start AS day_start,
|
|
|
|
|
sec.breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT minus(toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC'))), toIntervalDay(numbers.number)) AS day_start
|
|
|
|
|
FROM numbers(coalesce(dateDiff('day', assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 00:00:00', 6, 'UTC')), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-05 23:59:59', 6, 'UTC'))), 0)) AS numbers
|
|
|
|
|
UNION ALL SELECT toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 00:00:00', 6, 'UTC'))) AS day_start) AS ticks
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT ['$$_posthog_breakdown_null_$$'] AS breakdown_value) ARRAY
|
|
|
|
|
JOIN breakdown_value AS breakdown_value) AS sec
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$'], ['$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 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'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Windows'), 0)), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0))
|
|
|
|
|
GROUP BY day_start)
|
|
|
|
|
GROUP BY day_start
|
|
|
|
|
ORDER BY day_start ASC)
|
|
|
|
|
ORDER BY sum(count) DESC
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-22 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'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Windows'), 0)), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''))))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value
|
|
|
|
|
ORDER BY day_start ASC, breakdown_value ASC)
|
|
|
|
|
GROUP BY breakdown_value
|
|
|
|
|
ORDER BY sum(count) DESC, breakdown_value ASC
|
|
|
|
|
LIMIT 10000 SETTINGS readonly=2,
|
|
|
|
|
max_execution_time=60,
|
|
|
|
|
allow_experimental_object_type=1
|
|
|
|
@ -448,7 +462,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_weekly_active_users_aggregated
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(DISTINCT e__pdi.person_id) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -480,7 +494,7 @@
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
|
|
|
|
|
e__pdi.person_id AS actor_id,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['val', 'bor'], ['val', 'bor'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['val', 'bor'], ['val', 'bor'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -489,7 +503,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, '$pageview'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'bor'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 00:00:00', 6, 'UTC')), toIntervalDay(7))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, '$pageview'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'val'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'bor'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 00:00:00', 6, 'UTC')), toIntervalDay(7))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
GROUP BY timestamp, actor_id,
|
|
|
|
|
breakdown_value) AS e
|
|
|
|
|
WHERE and(ifNull(lessOrEquals(e.timestamp, plus(d.timestamp, toIntervalDay(1))), 0), ifNull(greater(e.timestamp, minus(d.timestamp, toIntervalDay(6))), 0))
|
|
|
|
@ -506,7 +520,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_weekly_active_users_aggregated_materialized
|
|
|
|
|
'''
|
|
|
|
|
SELECT nullIf(nullIf(e.mat_key, ''), 'null') AS value,
|
|
|
|
|
SELECT toString(nullIf(nullIf(e.mat_key, ''), 'null')) AS value,
|
|
|
|
|
count(DISTINCT e__pdi.person_id) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -538,7 +552,7 @@
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
|
|
|
|
|
e__pdi.person_id AS actor_id,
|
|
|
|
|
transform(ifNull(nullIf(nullIf(e.mat_key, ''), 'null'), '$$_posthog_breakdown_null_$$'), ['val', 'bor'], ['val', 'bor'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(nullIf(nullIf(e.mat_key, ''), 'null')), '$$_posthog_breakdown_null_$$'), ['val', 'bor'], ['val', 'bor'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -547,7 +561,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, '$pageview'), or(ifNull(equals(nullIf(nullIf(e.mat_key, ''), 'null'), 'val'), 0), ifNull(equals(nullIf(nullIf(e.mat_key, ''), 'null'), 'bor'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 00:00:00', 6, 'UTC')), toIntervalDay(7))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, '$pageview'), or(ifNull(equals(toString(nullIf(nullIf(e.mat_key, ''), 'null')), 'val'), 0), ifNull(equals(toString(nullIf(nullIf(e.mat_key, ''), 'null')), 'bor'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 00:00:00', 6, 'UTC')), toIntervalDay(7))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-11 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
GROUP BY timestamp, actor_id,
|
|
|
|
|
breakdown_value) AS e
|
|
|
|
|
WHERE and(ifNull(lessOrEquals(e.timestamp, plus(d.timestamp, toIntervalDay(1))), 0), ifNull(greater(e.timestamp, minus(d.timestamp, toIntervalDay(6))), 0))
|
|
|
|
@ -584,7 +598,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_weekly_active_users_daily_based_on_action.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(DISTINCT e__pdi.person_id) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -622,7 +636,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -654,7 +668,7 @@
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
|
|
|
|
|
e__pdi.person_id AS actor_id,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['val'], ['val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['val'], ['val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -679,7 +693,7 @@
|
|
|
|
|
FROM cohortpeople
|
|
|
|
|
WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 2))
|
|
|
|
|
GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
|
|
|
|
|
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'val'), 0)), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')), toIntervalDay(7))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'val'), 0)), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')), toIntervalDay(7))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
GROUP BY timestamp, actor_id,
|
|
|
|
|
breakdown_value) AS e
|
|
|
|
|
WHERE and(ifNull(lessOrEquals(e.timestamp, plus(d.timestamp, toIntervalDay(1))), 0), ifNull(greater(e.timestamp, minus(d.timestamp, toIntervalDay(6))), 0))
|
|
|
|
@ -699,7 +713,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_with_filter_groups_person_on_events
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
LEFT JOIN
|
|
|
|
@ -722,7 +736,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -743,7 +757,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['uh', 'oh'], ['uh', 'oh'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['uh', 'oh'], ['uh', 'oh'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT argMax(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', ''), groups._timestamp) AS properties___industry,
|
|
|
|
@ -753,7 +767,7 @@
|
|
|
|
|
WHERE and(equals(groups.team_id, 2), ifNull(equals(index, 0), 0))
|
|
|
|
|
GROUP BY groups.group_type_index,
|
|
|
|
|
groups.group_key) AS e__group_0 ON equals(e.`$group_0`, e__group_0.key)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), ifNull(equals(e__group_0.properties___industry, 'finance'), 0), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'uh'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'oh'), 0)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), ifNull(equals(e__group_0.properties___industry, 'finance'), 0), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'uh'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'oh'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -782,7 +796,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_breakdown_with_filter_groups_person_on_events_v2.1
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
LEFT JOIN
|
|
|
|
@ -805,7 +819,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -826,7 +840,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT ifNull(nullIf(e__override.override_person_id, '00000000-0000-0000-0000-000000000000'), e.person_id)) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['uh', 'oh'], ['uh', 'oh'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['uh', 'oh'], ['uh', 'oh'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT OUTER JOIN
|
|
|
|
|
(SELECT argMax(person_overrides.override_person_id, person_overrides.version) AS override_person_id,
|
|
|
|
@ -842,7 +856,7 @@
|
|
|
|
|
WHERE and(equals(groups.team_id, 2), ifNull(equals(index, 0), 0))
|
|
|
|
|
GROUP BY groups.group_type_index,
|
|
|
|
|
groups.group_key) AS e__group_0 ON equals(e.`$group_0`, e__group_0.key)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), ifNull(equals(e__group_0.properties___industry, 'finance'), 0), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'uh'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'oh'), 0)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-12 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), ifNull(equals(e__group_0.properties___industry, 'finance'), 0), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'uh'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', '')), 'oh'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -857,7 +871,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_dau_with_breakdown_filtering_with_sampling
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -872,7 +886,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -893,7 +907,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e__pdi.person_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['other_value', '$$_posthog_breakdown_null_$$', 'value'], ['other_value', '$$_posthog_breakdown_null_$$', 'value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['other_value', '$$_posthog_breakdown_null_$$', 'value'], ['other_value', '$$_posthog_breakdown_null_$$', 'value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1.0
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -902,7 +916,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0), isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0)))
|
|
|
|
|
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'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'other_value'), 0), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -917,7 +931,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_dau_with_breakdown_filtering_with_sampling.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -932,7 +946,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -953,7 +967,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e__pdi.person_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['other_value', '$$_posthog_breakdown_null_$$', 'value'], ['other_value', '$$_posthog_breakdown_null_$$', 'value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['other_value', '$$_posthog_breakdown_null_$$', 'value'], ['other_value', '$$_posthog_breakdown_null_$$', 'value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1.0
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -962,7 +976,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0), isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0)))
|
|
|
|
|
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'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'other_value'), 0), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -1242,7 +1256,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_mau_with_breakdown_filtering_and_prop_filter
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__pdi__person.`properties___$some_prop` AS value,
|
|
|
|
|
SELECT toString(e__pdi__person.`properties___$some_prop`) AS value,
|
|
|
|
|
count(DISTINCT e__pdi.person_id) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -1276,7 +1290,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -1308,7 +1322,7 @@
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
|
|
|
|
|
e__pdi.person_id AS actor_id,
|
|
|
|
|
transform(ifNull(e__pdi__person.`properties___$some_prop`, '$$_posthog_breakdown_null_$$'), ['some_val2', 'some_val'], ['some_val2', 'some_val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__pdi__person.`properties___$some_prop`), '$$_posthog_breakdown_null_$$'), ['some_val2', 'some_val'], ['some_val2', 'some_val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -1329,7 +1343,7 @@
|
|
|
|
|
WHERE equals(person.team_id, 2)
|
|
|
|
|
GROUP BY person.id
|
|
|
|
|
HAVING ifNull(equals(argMax(person.is_deleted, person.version), 0), 0))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, 'sign up'), ifNull(equals(e__pdi__person.properties___filter_prop, 'filter_val'), 0), or(ifNull(equals(e__pdi__person.`properties___$some_prop`, 'some_val2'), 0), ifNull(equals(e__pdi__person.`properties___$some_prop`, 'some_val'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), toIntervalDay(30))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, 'sign up'), ifNull(equals(e__pdi__person.properties___filter_prop, 'filter_val'), 0), or(ifNull(equals(toString(e__pdi__person.`properties___$some_prop`), 'some_val2'), 0), ifNull(equals(toString(e__pdi__person.`properties___$some_prop`), 'some_val'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), toIntervalDay(30))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
GROUP BY timestamp, actor_id,
|
|
|
|
|
breakdown_value) AS e
|
|
|
|
|
WHERE and(ifNull(lessOrEquals(e.timestamp, plus(d.timestamp, toIntervalDay(1))), 0), ifNull(greater(e.timestamp, minus(d.timestamp, toIntervalDay(29))), 0))
|
|
|
|
@ -1349,7 +1363,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_mau_with_breakdown_filtering_and_prop_filter_poe_v2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(DISTINCT ifNull(nullIf(e__override.override_person_id, '00000000-0000-0000-0000-000000000000'), e.person_id)) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
LEFT OUTER JOIN
|
|
|
|
@ -1370,7 +1384,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -1402,7 +1416,7 @@
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
|
|
|
|
|
ifNull(nullIf(e__override.override_person_id, '00000000-0000-0000-0000-000000000000'), e.person_id) AS actor_id,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['some_val2', 'some_val'], ['some_val2', 'some_val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['some_val2', 'some_val'], ['some_val2', 'some_val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT OUTER JOIN
|
|
|
|
|
(SELECT argMax(person_overrides.override_person_id, person_overrides.version) AS override_person_id,
|
|
|
|
@ -1410,7 +1424,7 @@
|
|
|
|
|
FROM person_overrides
|
|
|
|
|
WHERE equals(person_overrides.team_id, 2)
|
|
|
|
|
GROUP BY person_overrides.old_person_id) AS e__override ON equals(e.person_id, e__override.old_person_id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, 'sign up'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'filter_prop'), ''), 'null'), '^"|"$', ''), 'filter_val'), 0), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', ''), 'some_val2'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', ''), 'some_val'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), toIntervalDay(30))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, 'sign up'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'filter_prop'), ''), 'null'), '^"|"$', ''), 'filter_val'), 0), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', '')), 'some_val2'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, '$some_prop'), ''), 'null'), '^"|"$', '')), 'some_val'), 0))), ifNull(greaterOrEquals(timestamp, minus(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), toIntervalDay(30))), 0), ifNull(lessOrEquals(timestamp, assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), 0))
|
|
|
|
|
GROUP BY timestamp, actor_id,
|
|
|
|
|
breakdown_value) AS e
|
|
|
|
|
WHERE and(ifNull(lessOrEquals(e.timestamp, plus(d.timestamp, toIntervalDay(1))), 0), ifNull(greater(e.timestamp, minus(d.timestamp, toIntervalDay(29))), 0))
|
|
|
|
@ -1476,7 +1490,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_person_filtering_in_cohort_in_action.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -1503,7 +1517,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -1524,7 +1538,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -1538,7 +1552,7 @@
|
|
|
|
|
FROM cohortpeople
|
|
|
|
|
WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 2))
|
|
|
|
|
GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
|
|
|
|
|
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0)), or(isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0)))
|
|
|
|
|
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0)), or(isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'other_value'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -1573,7 +1587,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_person_filtering_in_cohort_in_action_poe_v2.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
LEFT OUTER JOIN
|
|
|
|
@ -1599,7 +1613,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -1620,7 +1634,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT OUTER JOIN
|
|
|
|
|
(SELECT argMax(person_overrides.override_person_id, person_overrides.version) AS override_person_id,
|
|
|
|
@ -1633,7 +1647,7 @@
|
|
|
|
|
FROM cohortpeople
|
|
|
|
|
WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 2))
|
|
|
|
|
GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
|
|
|
|
|
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0)), or(isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0)))
|
|
|
|
|
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0)), or(isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'other_value'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -2217,7 +2231,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_timezones_daily.4
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -2232,7 +2246,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -2253,7 +2267,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e__pdi.person_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['Mac'], ['Mac'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['Mac'], ['Mac'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -2262,7 +2276,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
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'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0))
|
|
|
|
|
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'), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')), 'Mac'), 0))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -2408,7 +2422,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_timezones_daily_minus_utc.4
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -2423,7 +2437,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -2444,7 +2458,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e__pdi.person_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'America/Phoenix')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['Mac'], ['Mac'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['Mac'], ['Mac'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -2453,7 +2467,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
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'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0))
|
|
|
|
|
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'), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')), 'Mac'), 0))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -2599,7 +2613,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_timezones_daily_plus_utc.4
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -2614,7 +2628,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -2635,7 +2649,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e__pdi.person_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'Asia/Tokyo')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['Mac'], ['Mac'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['Mac'], ['Mac'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -2644,7 +2658,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
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'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', ''), 'Mac'), 0))
|
|
|
|
|
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'), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$os'), ''), 'null'), '^"|"$', '')), 'Mac'), 0))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -2992,7 +3006,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trend_breakdown_user_props_with_filter_with_partial_property_pushdowns
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__pdi__person.properties___email AS value,
|
|
|
|
|
SELECT toString(e__pdi__person.properties___email) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -3027,7 +3041,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -3048,7 +3062,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(e__pdi__person.properties___email, '$$_posthog_breakdown_null_$$'), ['test2@posthog.com', 'test@gmail.com', 'test5@posthog.com', 'test4@posthog.com', 'test3@posthog.com'], ['test2@posthog.com', 'test@gmail.com', 'test5@posthog.com', 'test4@posthog.com', 'test3@posthog.com'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__pdi__person.properties___email), '$$_posthog_breakdown_null_$$'), ['test2@posthog.com', 'test@gmail.com', 'test5@posthog.com', 'test4@posthog.com', 'test3@posthog.com'], ['test2@posthog.com', 'test@gmail.com', 'test5@posthog.com', 'test4@posthog.com', 'test3@posthog.com'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id,
|
|
|
|
@ -3070,7 +3084,7 @@
|
|
|
|
|
WHERE equals(person.team_id, 2)
|
|
|
|
|
GROUP BY person.id
|
|
|
|
|
HAVING ifNull(equals(argMax(person.is_deleted, person.version), 0), 0))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-07-01 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), and(or(ifNull(notILike(e__pdi__person.properties___email, '%@posthog.com%'), 1), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'val'), 0)), or(ifNull(equals(e__pdi__person.`properties___$os`, 'android'), 0), ifNull(equals(e__pdi__person.`properties___$browser`, 'safari'), 0))), or(ifNull(equals(e__pdi__person.properties___email, 'test2@posthog.com'), 0), ifNull(equals(e__pdi__person.properties___email, 'test@gmail.com'), 0), ifNull(equals(e__pdi__person.properties___email, 'test5@posthog.com'), 0), ifNull(equals(e__pdi__person.properties___email, 'test4@posthog.com'), 0), ifNull(equals(e__pdi__person.properties___email, 'test3@posthog.com'), 0)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-07-01 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), and(or(ifNull(notILike(e__pdi__person.properties___email, '%@posthog.com%'), 1), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'val'), 0)), or(ifNull(equals(e__pdi__person.`properties___$os`, 'android'), 0), ifNull(equals(e__pdi__person.`properties___$browser`, 'safari'), 0))), or(ifNull(equals(toString(e__pdi__person.properties___email), 'test2@posthog.com'), 0), ifNull(equals(toString(e__pdi__person.properties___email), 'test@gmail.com'), 0), ifNull(equals(toString(e__pdi__person.properties___email), 'test5@posthog.com'), 0), ifNull(equals(toString(e__pdi__person.properties___email), 'test4@posthog.com'), 0), ifNull(equals(toString(e__pdi__person.properties___email), 'test3@posthog.com'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -3085,7 +3099,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trend_breakdown_user_props_with_filter_with_partial_property_pushdowns.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__pdi__person.properties___email AS value,
|
|
|
|
|
SELECT toString(e__pdi__person.properties___email) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -3120,7 +3134,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -3141,7 +3155,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(e.uuid) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(e__pdi__person.properties___email, '$$_posthog_breakdown_null_$$'), ['test2@posthog.com'], ['test2@posthog.com'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__pdi__person.properties___email), '$$_posthog_breakdown_null_$$'), ['test2@posthog.com'], ['test2@posthog.com'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id,
|
|
|
|
@ -3163,7 +3177,7 @@
|
|
|
|
|
WHERE equals(person.team_id, 2)
|
|
|
|
|
GROUP BY person.id
|
|
|
|
|
HAVING ifNull(equals(argMax(person.is_deleted, person.version), 0), 0))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-07-01 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), and(ifNull(equals(e__pdi__person.`properties___$os`, 'android'), 0), ifNull(equals(e__pdi__person.`properties___$browser`, 'chrome'), 0)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(ilike(e__pdi__person.properties___email, '%@posthog.com%'), 0)), ifNull(equals(e__pdi__person.properties___email, 'test2@posthog.com'), 0))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-07-01 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), and(ifNull(equals(e__pdi__person.`properties___$os`, 'android'), 0), ifNull(equals(e__pdi__person.`properties___$browser`, 'chrome'), 0)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'key'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(ilike(e__pdi__person.properties___email, '%@posthog.com%'), 0)), ifNull(equals(toString(e__pdi__person.properties___email), 'test2@posthog.com'), 0))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -3248,7 +3262,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_aggregate_by_distinct_id.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__pdi__person.`properties___$some_prop` AS value,
|
|
|
|
|
SELECT toString(e__pdi__person.`properties___$some_prop`) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -3281,7 +3295,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -3302,7 +3316,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e.distinct_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(e__pdi__person.`properties___$some_prop`, '$$_posthog_breakdown_null_$$'), ['some_val', '$$_posthog_breakdown_null_$$'], ['some_val', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__pdi__person.`properties___$some_prop`), '$$_posthog_breakdown_null_$$'), ['some_val', '$$_posthog_breakdown_null_$$'], ['some_val', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id,
|
|
|
|
@ -3322,7 +3336,7 @@
|
|
|
|
|
WHERE equals(person.team_id, 2)
|
|
|
|
|
GROUP BY person.id
|
|
|
|
|
HAVING ifNull(equals(argMax(person.is_deleted, person.version), 0), 0))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-24 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-31 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(e__pdi__person.`properties___$some_prop`, 'some_val'), 0), isNull(e__pdi__person.`properties___$some_prop`)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-24 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-31 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(toString(e__pdi__person.`properties___$some_prop`), 'some_val'), 0), isNull(toString(e__pdi__person.`properties___$some_prop`))))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -3415,7 +3429,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_aggregate_by_distinct_id.6
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_prop'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_prop'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-24 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-31 23:59:59', 6, 'UTC')))), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-24 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-31 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up')))
|
|
|
|
@ -3430,7 +3444,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -3451,9 +3465,9 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e.distinct_id) AS total,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_prop'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$'], ['$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_prop'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$'], ['$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-24 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-31 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_prop'), ''), 'null'), '^"|"$', '')))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-24 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-31 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_prop'), ''), 'null'), '^"|"$', ''))))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -3520,7 +3534,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_breakdown_cumulative
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -3535,7 +3549,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT day_start AS day_start,
|
|
|
|
|
sum(count) OVER (PARTITION BY breakdown_value
|
|
|
|
@ -3561,7 +3575,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT e__pdi.person_id) AS total,
|
|
|
|
|
min(toStartOfDay(toTimeZone(e.timestamp, 'UTC'))) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -3570,7 +3584,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
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'), or(isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0)))
|
|
|
|
|
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'), or(isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'other_value'), 0)))
|
|
|
|
|
GROUP BY e__pdi.person_id,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -3585,7 +3599,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_breakdown_cumulative_poe_v2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(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')))), and(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')))
|
|
|
|
@ -3600,7 +3614,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT day_start AS day_start,
|
|
|
|
|
sum(count) OVER (PARTITION BY breakdown_value
|
|
|
|
@ -3626,7 +3640,7 @@
|
|
|
|
|
ORDER BY sec.breakdown_value ASC, day_start ASC
|
|
|
|
|
UNION ALL SELECT count(DISTINCT ifNull(nullIf(e__override.override_person_id, '00000000-0000-0000-0000-000000000000'), e.person_id)) AS total,
|
|
|
|
|
min(toStartOfDay(toTimeZone(e.timestamp, 'UTC'))) AS day_start,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], ['$$_posthog_breakdown_null_$$', 'value', 'other_value'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
LEFT OUTER JOIN
|
|
|
|
|
(SELECT argMax(person_overrides.override_person_id, person_overrides.version) AS override_person_id,
|
|
|
|
@ -3634,7 +3648,7 @@
|
|
|
|
|
FROM person_overrides
|
|
|
|
|
WHERE equals(person_overrides.team_id, 2)
|
|
|
|
|
GROUP BY person_overrides.old_person_id) AS e__override ON equals(e.person_id, e__override.old_person_id)
|
|
|
|
|
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'), or(isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0)))
|
|
|
|
|
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'), or(isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'other_value'), 0)))
|
|
|
|
|
GROUP BY ifNull(nullIf(e__override.override_person_id, '00000000-0000-0000-0000-000000000000'), e.person_id),
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
@ -3649,7 +3663,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_breakdown_with_session_property_single_aggregate_math_and_breakdown
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
max(e__session.duration) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -3672,7 +3686,7 @@
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT any(e__session.duration) AS session_duration,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['value2', 'value1', '$$_posthog_breakdown_null_$$'], ['value2', 'value1', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['value2', 'value1', '$$_posthog_breakdown_null_$$'], ['value2', 'value1', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT events.`$session_id` AS id,
|
|
|
|
@ -3680,7 +3694,7 @@
|
|
|
|
|
FROM events
|
|
|
|
|
WHERE and(equals(events.team_id, 2), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), ifNull(notEquals(id, ''), 1))
|
|
|
|
|
GROUP BY id) AS e__session ON equals(e.`$session_id`, e__session.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value2'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value1'), 0), isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value2'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value1'), 0), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')))))
|
|
|
|
|
GROUP BY e__session.id,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY breakdown_value
|
|
|
|
@ -3691,7 +3705,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_breakdown_with_session_property_single_aggregate_math_and_breakdown.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
max(e__session.duration) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -3714,7 +3728,7 @@
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT any(e__session.duration) AS session_duration,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['value2', 'value1', '$$_posthog_breakdown_null_$$'], ['value2', 'value1', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['value2', 'value1', '$$_posthog_breakdown_null_$$'], ['value2', 'value1', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT events.`$session_id` AS id,
|
|
|
|
@ -3722,7 +3736,7 @@
|
|
|
|
|
FROM events
|
|
|
|
|
WHERE and(equals(events.team_id, 2), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), ifNull(notEquals(id, ''), 1))
|
|
|
|
|
GROUP BY id) AS e__session ON equals(e.`$session_id`, e__session.id)
|
|
|
|
|
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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value2'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value1'), 0), isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''))))
|
|
|
|
|
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'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value2'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value1'), 0), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')))))
|
|
|
|
|
GROUP BY e__session.id,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY breakdown_value
|
|
|
|
@ -3854,7 +3868,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_count_per_user_average_aggregated_with_event_property_breakdown_with_sampling
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
count(e.uuid) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-07 23:59:59', 6, 'UTC')))), equals(e.event, 'viewed video'))
|
|
|
|
@ -3874,7 +3888,7 @@
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT count(e.uuid) AS total,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['red', 'blue', '$$_posthog_breakdown_null_$$'], ['red', 'blue', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['red', 'blue', '$$_posthog_breakdown_null_$$'], ['red', 'blue', '$$_posthog_breakdown_null_$$'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1.0
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,
|
|
|
|
@ -3883,7 +3897,7 @@
|
|
|
|
|
WHERE equals(person_distinct_id2.team_id, 2)
|
|
|
|
|
GROUP BY person_distinct_id2.distinct_id
|
|
|
|
|
HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, 'viewed video'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', ''), 'red'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', ''), 'blue'), 0), isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '')))), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')), toIntervalDay(0))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-07 23:59:59', 6, 'UTC'))))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), and(equals(e.event, 'viewed video'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '')), 'red'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', '')), 'blue'), 0), isNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'color'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), minus(assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC')), toIntervalDay(0))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-07 23:59:59', 6, 'UTC'))))
|
|
|
|
|
GROUP BY e__pdi.person_id,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY breakdown_value)
|
|
|
|
@ -4098,7 +4112,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_person_breakdown_with_session_property_single_aggregate_math_and_breakdown
|
|
|
|
|
'''
|
|
|
|
|
SELECT e__pdi__person.`properties___$some_prop` AS value,
|
|
|
|
|
SELECT toString(e__pdi__person.`properties___$some_prop`) AS value,
|
|
|
|
|
max(e__session.duration) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -4139,7 +4153,7 @@
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT any(e__session.duration) AS session_duration,
|
|
|
|
|
transform(ifNull(e__pdi__person.`properties___$some_prop`, '$$_posthog_breakdown_null_$$'), ['some_val', 'another_val'], ['some_val', 'another_val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
transform(ifNull(toString(e__pdi__person.`properties___$some_prop`), '$$_posthog_breakdown_null_$$'), ['some_val', 'another_val'], ['some_val', 'another_val'], '$$_posthog_breakdown_other_$$') AS breakdown_value
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(SELECT events.`$session_id` AS id,
|
|
|
|
@ -4165,7 +4179,7 @@
|
|
|
|
|
WHERE equals(person.team_id, 2)
|
|
|
|
|
GROUP BY person.id
|
|
|
|
|
HAVING ifNull(equals(argMax(person.is_deleted, person.version), 0), 0))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(e__pdi__person.`properties___$some_prop`, 'some_val'), 0), ifNull(equals(e__pdi__person.`properties___$some_prop`, 'another_val'), 0)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(toString(e__pdi__person.`properties___$some_prop`), 'some_val'), 0), ifNull(equals(toString(e__pdi__person.`properties___$some_prop`), 'another_val'), 0)))
|
|
|
|
|
GROUP BY e__session.id,
|
|
|
|
|
breakdown_value)
|
|
|
|
|
GROUP BY breakdown_value
|
|
|
|
@ -4316,7 +4330,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_with_session_property_total_volume_math_with_breakdowns
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
max(e__session.duration) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -4337,7 +4351,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -4361,7 +4375,7 @@
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT any(e__session.duration) AS session_duration,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['value2', 'value1'], ['value2', 'value1'], '$$_posthog_breakdown_other_$$') AS breakdown_value,
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['value2', 'value1'], ['value2', 'value1'], '$$_posthog_breakdown_other_$$') AS breakdown_value,
|
|
|
|
|
toStartOfWeek(toTimeZone(e.timestamp, 'UTC'), 0) AS day_start
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -4370,7 +4384,7 @@
|
|
|
|
|
FROM events
|
|
|
|
|
WHERE and(equals(events.team_id, 2), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), ifNull(notEquals(id, ''), 1))
|
|
|
|
|
GROUP BY id) AS e__session ON equals(e.`$session_id`, e__session.id)
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value2'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value1'), 0)))
|
|
|
|
|
WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')), 0)), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), equals(e.event, 'sign up'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value2'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value1'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
e__session.id,
|
|
|
|
|
breakdown_value,
|
|
|
|
@ -4389,7 +4403,7 @@
|
|
|
|
|
# ---
|
|
|
|
|
# name: TestTrends.test_trends_with_session_property_total_volume_math_with_breakdowns.2
|
|
|
|
|
'''
|
|
|
|
|
SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '') AS value,
|
|
|
|
|
SELECT toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')) AS value,
|
|
|
|
|
max(e__session.duration) AS count
|
|
|
|
|
FROM events AS e
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -4410,7 +4424,7 @@
|
|
|
|
|
'''
|
|
|
|
|
SELECT groupArray(day_start) AS date,
|
|
|
|
|
groupArray(count) AS total,
|
|
|
|
|
ifNull(toString(breakdown_value), '') AS breakdown_value
|
|
|
|
|
ifNull(toString(breakdown_value), '$$_posthog_breakdown_null_$$') AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT sum(total) AS count,
|
|
|
|
|
day_start AS day_start,
|
|
|
|
@ -4434,7 +4448,7 @@
|
|
|
|
|
breakdown_value AS breakdown_value
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT any(e__session.duration) AS session_duration,
|
|
|
|
|
transform(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), '$$_posthog_breakdown_null_$$'), ['value2', 'value1'], ['value2', 'value1'], '$$_posthog_breakdown_other_$$') AS breakdown_value,
|
|
|
|
|
transform(ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), '$$_posthog_breakdown_null_$$'), ['value2', 'value1'], ['value2', 'value1'], '$$_posthog_breakdown_other_$$') AS breakdown_value,
|
|
|
|
|
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start
|
|
|
|
|
FROM events AS e SAMPLE 1
|
|
|
|
|
INNER JOIN
|
|
|
|
@ -4443,7 +4457,7 @@
|
|
|
|
|
FROM events
|
|
|
|
|
WHERE and(equals(events.team_id, 2), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 00:00:00', 6, 'UTC')))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), ifNull(notEquals(id, ''), 1))
|
|
|
|
|
GROUP BY id) AS e__session ON equals(e.`$session_id`, e__session.id)
|
|
|
|
|
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'), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value2'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value1'), 0)))
|
|
|
|
|
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'), or(ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value2'), 0), ifNull(equals(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), 'value1'), 0)))
|
|
|
|
|
GROUP BY day_start,
|
|
|
|
|
e__session.id,
|
|
|
|
|
breakdown_value,
|
|
|
|
|