-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ae8293
commit 3c8ab2f
Showing
3 changed files
with
1,187 additions
and
0 deletions.
There are no files selected for viewing
252 changes: 252 additions & 0 deletions
252
ee/clickhouse/queries/test/__snapshots__/test_breakdown_props.ambr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
# serializer version: 1 | ||
# name: TestBreakdownProps.test_breakdown_group_props | ||
''' | ||
|
||
SELECT replaceRegexpAll(JSONExtractRaw(group_properties_0, 'industry'), '^"|"$', '') AS value, | ||
count(*) as count | ||
FROM events e | ||
LEFT JOIN | ||
(SELECT group_key, | ||
argMax(group_properties, _timestamp) AS group_properties_0 | ||
FROM groups | ||
WHERE team_id = 99999 | ||
AND group_type_index = 0 | ||
GROUP BY group_key) groups_0 ON "$group_0" == groups_0.group_key | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') | ||
AND ((isNull(replaceRegexpAll(JSONExtractRaw(group_properties_0, 'out'), '^"|"$', '')) | ||
OR NOT JSONHas(group_properties_0, 'out'))) | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 6 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_group_props.1 | ||
''' | ||
|
||
SELECT replaceRegexpAll(JSONExtractRaw(group_properties_0, 'industry'), '^"|"$', '') AS value, | ||
count(*) as count | ||
FROM events e | ||
LEFT JOIN | ||
(SELECT group_key, | ||
argMax(group_properties, _timestamp) AS group_properties_0 | ||
FROM groups | ||
WHERE team_id = 99999 | ||
AND group_type_index = 0 | ||
GROUP BY group_key) groups_0 ON "$group_0" == groups_0.group_key | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') | ||
AND ((isNull(replaceRegexpAll(JSONExtractRaw(group_properties_0, 'out'), '^"|"$', '')) | ||
OR NOT JSONHas(group_properties_0, 'out'))) | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 6 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_person_props | ||
''' | ||
|
||
SELECT replaceRegexpAll(JSONExtractRaw(person_props, '$browser'), '^"|"$', '') AS value, | ||
count(*) as count | ||
FROM events e | ||
INNER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 99999 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
INNER JOIN | ||
(SELECT id, | ||
argMax(properties, version) as person_props | ||
FROM person | ||
WHERE team_id = 99999 | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1) person ON pdi.person_id = person.id | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2019-12-21 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-04 23:59:59', 'UTC') | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 6 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_person_props_materialized | ||
''' | ||
|
||
SELECT "pmat_$browser" AS value, | ||
count(*) as count | ||
FROM events e | ||
INNER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 99999 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
INNER JOIN | ||
(SELECT id, | ||
argMax(pmat_$browser, version) as pmat_$browser | ||
FROM person | ||
WHERE team_id = 99999 | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1) person ON pdi.person_id = person.id | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2019-12-21 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-04 23:59:59', 'UTC') | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 6 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_person_props_with_entity_filter_and_or_props_with_partial_pushdown | ||
''' | ||
|
||
SELECT replaceRegexpAll(JSONExtractRaw(person_props, '$browser'), '^"|"$', '') AS value, | ||
count(*) as count | ||
FROM events e | ||
INNER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 99999 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
INNER JOIN | ||
(SELECT id, | ||
argMax(properties, version) as person_props | ||
FROM person | ||
WHERE team_id = 99999 | ||
AND id IN | ||
(SELECT id | ||
FROM person | ||
WHERE team_id = 99999 | ||
AND ((replaceRegexpAll(JSONExtractRaw(properties, '$browser'), '^"|"$', '') ILIKE '%test%')) ) | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 | ||
AND ((replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$browser'), '^"|"$', '') ILIKE '%test%')) SETTINGS optimize_aggregation_in_order = 1) person ON pdi.person_id = person.id | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2019-12-21 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-04 23:59:59', 'UTC') | ||
AND ((has(['test2'], replaceRegexpAll(JSONExtractRaw(person_props, '$os'), '^"|"$', '')) | ||
OR has(['val'], replaceRegexpAll(JSONExtractRaw(e.properties, 'key'), '^"|"$', '')))) | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 6 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_session_props | ||
''' | ||
|
||
SELECT sessions.session_duration AS value, | ||
count(*) as count | ||
FROM events e | ||
INNER JOIN | ||
(SELECT "$session_id", | ||
dateDiff('second', min(timestamp), max(timestamp)) as session_duration | ||
FROM events | ||
WHERE "$session_id" != '' | ||
AND team_id = 99999 | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-02 00:00:00', 'UTC') - INTERVAL 24 HOUR | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') + INTERVAL 24 HOUR | ||
GROUP BY "$session_id") AS sessions ON sessions."$session_id" = e."$session_id" | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-02 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 26 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_with_math_property_session | ||
''' | ||
|
||
SELECT replaceRegexpAll(JSONExtractRaw(person_props, '$browser'), '^"|"$', '') AS value, | ||
sum(session_duration) as count | ||
FROM events e | ||
INNER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 99999 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
INNER JOIN | ||
(SELECT id, | ||
argMax(properties, version) as person_props | ||
FROM person | ||
WHERE team_id = 99999 | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1) person ON pdi.person_id = person.id | ||
INNER JOIN | ||
(SELECT "$session_id", | ||
dateDiff('second', min(timestamp), max(timestamp)) as session_duration | ||
FROM events | ||
WHERE "$session_id" != '' | ||
AND team_id = 99999 | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-02 00:00:00', 'UTC') - INTERVAL 24 HOUR | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') + INTERVAL 24 HOUR | ||
GROUP BY "$session_id") AS sessions ON sessions."$session_id" = e."$session_id" | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-02 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 26 | ||
OFFSET 0 | ||
''' | ||
# --- | ||
# name: TestBreakdownProps.test_breakdown_with_math_property_session.1 | ||
''' | ||
|
||
SELECT replaceRegexpAll(JSONExtractRaw(person_props, '$browser'), '^"|"$', '') AS value, | ||
count(*) as count | ||
FROM events e | ||
INNER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 99999 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
INNER JOIN | ||
(SELECT id, | ||
argMax(properties, version) as person_props | ||
FROM person | ||
WHERE team_id = 99999 | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1) person ON pdi.person_id = person.id | ||
INNER JOIN | ||
(SELECT "$session_id", | ||
dateDiff('second', min(timestamp), max(timestamp)) as session_duration | ||
FROM events | ||
WHERE "$session_id" != '' | ||
AND team_id = 99999 | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-02 00:00:00', 'UTC') - INTERVAL 24 HOUR | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') + INTERVAL 24 HOUR | ||
GROUP BY "$session_id") AS sessions ON sessions."$session_id" = e."$session_id" | ||
WHERE team_id = 99999 | ||
AND event = '$pageview' | ||
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-02 00:00:00', 'UTC') | ||
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC') | ||
GROUP BY value | ||
ORDER BY count DESC, value DESC | ||
LIMIT 26 | ||
OFFSET 0 | ||
''' | ||
# --- |
Oops, something went wrong.