Skip to content

Commit

Permalink
Merge branch 'master' into chore/snapshot-notebook-template
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Sep 13, 2023
2 parents dc59ab3 + 5044177 commit 2a4595a
Show file tree
Hide file tree
Showing 65 changed files with 1,717 additions and 691 deletions.
3 changes: 3 additions & 0 deletions docker-compose.hobby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ services:
extends:
file: docker-compose.base.yml
service: db
# Pin to postgres 12 until we have a process for pg_upgrade to postgres 15 for exsisting installations
image: ${DOCKER_REGISTRY_PREFIX:-}postgres:12-alpine
volumes:
- postgres-data:/var/lib/postgresql/data

redis:
extends:
file: docker-compose.base.yml
Expand Down
20 changes: 10 additions & 10 deletions ee/clickhouse/models/test/__snapshots__/test_cohort.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
(SELECT pdi.person_id AS person_id,
countIf(timestamp > now() - INTERVAL 2 year
AND timestamp < now()
AND event = '$pageview') > 0 AS performed_event_condition_15_level_level_0_level_0_level_0_0
AND event = '$pageview') > 0 AS performed_event_condition_17_level_level_0_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand Down Expand Up @@ -113,7 +113,7 @@
HAVING max(is_deleted) = 0
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))))) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_15_level_level_0_level_0_level_0_0)))) ) as person
AND ((((performed_event_condition_17_level_level_0_level_0_level_0_0)))) ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand Down Expand Up @@ -148,7 +148,7 @@
(SELECT pdi.person_id AS person_id,
countIf(timestamp > now() - INTERVAL 2 year
AND timestamp < now()
AND event = '$pageview') > 0 AS performed_event_condition_17_level_level_0_level_0_level_0_0
AND event = '$pageview') > 0 AS performed_event_condition_19_level_level_0_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand Down Expand Up @@ -178,7 +178,7 @@
HAVING max(is_deleted) = 0
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))))) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_17_level_level_0_level_0_level_0_0)))) ) ))
AND ((((performed_event_condition_19_level_level_0_level_0_level_0_0)))) ) ))
'
---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_for_behavioural_cohorts
Expand All @@ -195,7 +195,7 @@
FROM
(SELECT pdi.person_id AS person_id,
minIf(timestamp, event = 'signup') >= now() - INTERVAL 15 day
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_18_level_level_0_level_0_0
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_20_level_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand All @@ -208,7 +208,7 @@
AND event IN ['signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND (((first_time_condition_18_level_level_0_level_0_0))) ) as person
AND (((first_time_condition_20_level_level_0_level_0_0))) ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand Down Expand Up @@ -237,9 +237,9 @@
(SELECT pdi.person_id AS person_id,
countIf(timestamp > now() - INTERVAL 2 year
AND timestamp < now()
AND event = '$pageview') > 0 AS performed_event_condition_19_level_level_0_level_0_level_0_0,
AND event = '$pageview') > 0 AS performed_event_condition_21_level_level_0_level_0_level_0_0,
minIf(timestamp, event = 'signup') >= now() - INTERVAL 15 day
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_19_level_level_0_level_1_level_0_level_0_level_0_0
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_21_level_level_0_level_1_level_0_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand All @@ -252,8 +252,8 @@
AND event IN ['$pageview', 'signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND ((((performed_event_condition_19_level_level_0_level_0_level_0_0))
AND ((((NOT first_time_condition_19_level_level_0_level_1_level_0_level_0_level_0_0)))))) ) as person
AND ((((performed_event_condition_21_level_level_0_level_0_level_0_0))
AND ((((NOT first_time_condition_21_level_level_0_level_1_level_0_level_0_level_0_0)))))) ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/models/test/__snapshots__/test_property.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
))
',
<class 'dict'> {
'global_cohort_id_0': 47,
'global_cohort_id_0': 1,
'global_version_0': None,
},
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results
'
/* user_id:51 celery:posthog.celery.sync_insight_caching_state */
/* user_id:138 celery:posthog.celery.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
Expand All @@ -12,50 +12,78 @@
---
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results.1
'
/* celery:posthog.celery.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
WHERE timestamp > date_sub(DAY, 3, now())
AND timestamp < now()
GROUP BY team_id
ORDER BY age;
/* user_id:0 request:_snapshot_ */
SELECT groupArray(value)
FROM
(SELECT replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '') AS value,
count(*) as count
FROM events e
WHERE team_id = 2
AND event = '$pageview'
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC')
GROUP BY value
ORDER BY count DESC, value DESC
LIMIT 25
OFFSET 0)
'
---
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results.2
'
/* celery:posthog.celery.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
WHERE timestamp > date_sub(DAY, 3, now())
AND timestamp < now()
GROUP BY team_id
ORDER BY age;
/* user_id:0 request:_snapshot_ */
SELECT groupArray(day_start) as date,
groupArray(count) AS total,
breakdown_value
FROM
(SELECT SUM(total) as count,
day_start,
breakdown_value
FROM
(SELECT *
FROM
(SELECT toUInt16(0) AS total,
ticks.day_start as day_start,
breakdown_value
FROM
(SELECT toStartOfDay(toDateTime('2020-01-06 00:00:00', 'UTC')) - toIntervalDay(number) as day_start
FROM numbers(6)
UNION ALL SELECT toStartOfDay(toDateTime('2020-01-01 00:00:00', 'UTC')) as day_start) as ticks
CROSS JOIN
(SELECT breakdown_value
FROM
(SELECT ['control', 'test', 'ablahebf', ''] as breakdown_value) ARRAY
JOIN breakdown_value) as sec
ORDER BY breakdown_value,
day_start
UNION ALL SELECT count(*) as total,
toStartOfDay(toTimeZone(toDateTime(timestamp, 'UTC'), 'UTC')) as day_start,
replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '') as breakdown_value
FROM events e
WHERE e.team_id = 2
AND event = '$pageview'
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC')
AND replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '') in (['control', 'test', 'ablahebf', ''])
GROUP BY day_start,
breakdown_value))
GROUP BY day_start,
breakdown_value
ORDER BY breakdown_value,
day_start)
GROUP BY breakdown_value
ORDER BY breakdown_value
'
---
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results.3
'
/* celery:posthog.celery.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
WHERE timestamp > date_sub(DAY, 3, now())
AND timestamp < now()
GROUP BY team_id
ORDER BY age;
'
---
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results.4
'
/* user_id:0 request:_snapshot_ */
SELECT groupArray(value)
FROM
(SELECT replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '') AS value,
(SELECT array(replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '')) AS value,
count(*) as count
FROM events e
WHERE team_id = 2
AND event = '$pageview'
AND event IN ['$pageleave_funnel', '$pageview_funnel']
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC')
GROUP BY value
Expand All @@ -64,6 +92,78 @@
OFFSET 0)
'
---
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results.4
'
/* user_id:0 request:_snapshot_ */
SELECT countIf(steps = 1) step_1,
countIf(steps = 2) step_2,
avg(step_1_average_conversion_time_inner) step_1_average_conversion_time,
median(step_1_median_conversion_time_inner) step_1_median_conversion_time,
prop
FROM
(SELECT aggregation_target,
steps,
avg(step_1_conversion_time) step_1_average_conversion_time_inner,
median(step_1_conversion_time) step_1_median_conversion_time_inner ,
prop
FROM
(SELECT aggregation_target,
steps,
max(steps) over (PARTITION BY aggregation_target,
prop) as max_steps,
step_1_conversion_time ,
prop
FROM
(SELECT *,
if(latest_0 <= latest_1
AND latest_1 <= latest_0 + INTERVAL 14 DAY, 2, 1) AS steps ,
if(isNotNull(latest_1)
AND latest_1 <= latest_0 + INTERVAL 14 DAY, dateDiff('second', toDateTime(latest_0), toDateTime(latest_1)), NULL) step_1_conversion_time,
prop
FROM
(SELECT aggregation_target, timestamp, step_0,
latest_0,
step_1,
min(latest_1) over (PARTITION by aggregation_target,
prop
ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) latest_1 ,
if(has([['test'], ['control'], ['']], prop), prop, ['Other']) as prop
FROM
(SELECT *,
if(notEmpty(arrayFilter(x -> notEmpty(x), prop_vals)), prop_vals, ['']) as prop
FROM
(SELECT e.timestamp as timestamp,
pdi.person_id as aggregation_target,
pdi.person_id as person_id ,
if(event = '$pageview_funnel', 1, 0) as step_0,
if(step_0 = 1, timestamp, null) as latest_0,
if(event = '$pageleave_funnel', 1, 0) as step_1,
if(step_1 = 1, timestamp, null) as latest_1,
array(replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '')) AS prop_basic,
prop_basic as prop,
argMinIf(prop, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop))) over (PARTITION by aggregation_target) as prop_vals
FROM events e
INNER JOIN
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id
WHERE team_id = 2
AND event IN ['$pageleave_funnel', '$pageview_funnel']
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC')
AND (step_0 = 1
OR step_1 = 1) )))
WHERE step_0 = 1 ))
GROUP BY aggregation_target,
steps,
prop
HAVING steps = max_steps)
GROUP BY prop
'
---
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results.5
'
/* user_id:0 request:_snapshot_ */
Expand Down
Loading

0 comments on commit 2a4595a

Please sign in to comment.