:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(hogql): promote events IN-subqueries to GLOBAL IN (#80817)
Andy Zhaoe5e718bfc0aa
diff --git a/ee/clickhouse/models/test/__snapshots__/test_cohort.ambr b/ee/clickhouse/models/test/__snapshots__/test_cohort.ambrindex 0badb9672750..cef97d8e9187 100644--- a/ee/clickhouse/models/test/__snapshots__/test_cohort.ambr+++ b/ee/clickhouse/models/test/__snapshots__/test_cohort.ambr@@ -239,40 +239,29 @@WHERE equals(person_distinct_id2.team_id, 99999)GROUP BY person_distinct_id2.distinct_idHAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.person_id, ((- (SELECT source.id AS id- FROM- (SELECT actor_id AS actor_id,- count() AS event_count,- groupUniqArray(distinct_id) AS event_distinct_ids,- max(timestamp) AS last_seen,- actor_id AS id- FROM- (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id,- toTimeZone(e.timestamp, 'UTC') AS timestamp,- e.uuid AS uuid,- e.distinct_id AS distinct_id- FROM events AS e- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)- WHERE and(equals(e.team_id, 99999), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), equals(e.event, '$pageview')))- GROUP BY actor_id) AS source- ORDER BY source.id ASC SETTINGS optimize_aggregation_in_order=1,- join_algorithm='auto'))- EXCEPT (- (SELECT cohort_people.person_id AS id- FROM- (SELECT DISTINCT cohortpeople.person_id AS person_id,- cohortpeople.cohort_id AS cohort_id,- cohortpeople.team_id AS team_id- FROM cohortpeople- WHERE 0) AS cohort_people- WHERE and(equals(cohort_people.cohort_id, 99999), equals(cohort_people.team_id, 99999))))))+ WHERE globalIn(person_distinct_ids.person_id, ((+ (SELECT source.id AS id+ FROM+ (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, max(timestamp) AS last_seen, actor_id AS id+ FROM+ (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id, toTimeZone(e.timestamp, 'UTC') AS timestamp, e.uuid AS uuid, e.distinct_id AS distinct_id+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), equals(e.event, '$pageview')))+ GROUP BY actor_id) AS source+ ORDER BY source.id ASC SETTINGS optimize_aggregation_in_order=1, join_algorithm='auto'))+ EXCEPT (+ (SELECT cohort_people.person_id AS id+ FROM+ (SELECT DISTINCT cohortpeople.person_id AS person_id, cohortpeople.cohort_id AS cohort_id, cohortpeople.team_id AS team_id+ FROM cohortpeople+ WHERE 0) AS cohort_people+ WHERE and(equals(cohort_people.cohort_id, 99999), equals(cohort_people.team_id, 99999))))))LIMIT 1000000000)))'''# ---diff --git a/ee/clickhouse/queries/test/__snapshots__/test_related_actors_query.ambr b/ee/clickhouse/queries/test/__snapshots__/test_related_actors_query.ambrindex d60304ead56e..5dc520101d57 100644--- a/ee/clickhouse/queries/test/__snapshots__/test_related_actors_query.ambr+++ b/ee/clickhouse/queries/test/__snapshots__/test_related_actors_query.ambr@@ -37,10 +37,10 @@WHERE equals(person_distinct_id2.team_id, 99999)GROUP BY person_distinct_id2.distinct_idHAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.distinct_id,- (SELECT events.distinct_id AS distinct_id- FROM events- WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('2024-12-01 12:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.`$group_0`, 'org:1'))))+ WHERE globalIn(person_distinct_ids.distinct_id,+ (SELECT events.distinct_id AS distinct_id+ FROM events+ WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('2024-12-01 12:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.`$group_0`, 'org:1'))))LIMIT 100 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,diff --git a/ee/clickhouse/views/test/__snapshots__/test_clickhouse_groups.ambr b/ee/clickhouse/views/test/__snapshots__/test_clickhouse_groups.ambrindex e7308bbddf74..36f17efb932d 100644--- a/ee/clickhouse/views/test/__snapshots__/test_clickhouse_groups.ambr+++ b/ee/clickhouse/views/test/__snapshots__/test_clickhouse_groups.ambr@@ -10,10 +10,10 @@WHERE equals(person_distinct_id2.team_id, 99999)GROUP BY person_distinct_id2.distinct_idHAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.distinct_id,- (SELECT events.distinct_id AS distinct_id- FROM events- WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('2021-02-09 00:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.`$group_0`, '0::0'))))+ WHERE globalIn(person_distinct_ids.distinct_id,+ (SELECT events.distinct_id AS distinct_id+ FROM events+ WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('2021-02-09 00:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.`$group_0`, '0::0'))))LIMIT 100 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,diff --git a/posthog/api/test/__snapshots__/test_query.ambr b/posthog/api/test/__snapshots__/test_query.ambrindex e602262d6275..c5ec28ba4dc1 100644--- a/posthog/api/test/__snapshots__/test_query.ambr+++ b/posthog/api/test/__snapshots__/test_query.ambr@@ -8,12 +8,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -39,12 +39,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -70,12 +70,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'path'), ''), 'null'), '^"|"$', '')), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'path'), ''), 'null'), '^"|"$', '')), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'path'), ''), 'null'), '^"|"$', '')), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'path'), ''), 'null'), '^"|"$', '')), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -101,12 +101,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val3'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -132,12 +132,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^path), '{}'), toJSONString(events.properties.^path), if(isNull(events.properties.path), NULL, if(startsWith(dynamicType(events.properties.path), 'DateTime'), replaceOne(toString(events.properties.path), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.path), 'Array'), startsWith(dynamicType(events.properties.path), 'Map'), startsWith(dynamicType(events.properties.path), 'Tuple')), toJSONString(events.properties.path), toString(events.properties.path)))))), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^path), '{}'), toJSONString(events.properties.^path), if(isNull(events.properties.path), NULL, if(startsWith(dynamicType(events.properties.path), 'DateTime'), replaceOne(toString(events.properties.path), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.path), 'Array'), startsWith(dynamicType(events.properties.path), 'Map'), startsWith(dynamicType(events.properties.path), 'Tuple')), toJSONString(events.properties.path), toString(events.properties.path)))))), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^path), '{}'), toJSONString(events.properties.^path), if(isNull(events.properties.path), NULL, if(startsWith(dynamicType(events.properties.path), 'DateTime'), replaceOne(toString(events.properties.path), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.path), 'Array'), startsWith(dynamicType(events.properties.path), 'Map'), startsWith(dynamicType(events.properties.path), 'Tuple')), toJSONString(events.properties.path), toString(events.properties.path)))))), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^path), '{}'), toJSONString(events.properties.^path), if(isNull(events.properties.path), NULL, if(startsWith(dynamicType(events.properties.path), 'DateTime'), replaceOne(toString(events.properties.path), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.path), 'Array'), startsWith(dynamicType(events.properties.path), 'Map'), startsWith(dynamicType(events.properties.path), 'Tuple')), toJSONString(events.properties.path), toString(events.properties.path)))))), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -163,12 +163,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -190,12 +190,12 @@/* user_id:0 request:_snapshot_ */SELECT events.event AS eventFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -217,12 +217,12 @@/* user_id:0 request:_snapshot_ */SELECT events.event AS eventFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -244,12 +244,12 @@/* user_id:0 request:_snapshot_ */SELECT events.event AS eventFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -271,12 +271,12 @@/* user_id:0 request:_snapshot_ */SELECT events.event AS eventFROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), less(events.timestamp, toDateTime64('2022-01-12 12:14:00.000000', 6, 'UTC')))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -298,12 +298,12 @@/* user_id:0 request:_snapshot_ */SELECT events.event AS eventFROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2022-01-01 00:00:00.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2019-01-12 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -325,12 +325,12 @@/* user_id:0 request:_snapshot_ */SELECT events.event AS eventFROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), less(events.timestamp, toDateTime64('2023-01-12 12:14:05.000000', 6, 'UTC')))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -508,12 +508,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -565,12 +565,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -596,12 +596,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -653,12 +653,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -684,12 +684,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(equals(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))), 'test_val2'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -715,12 +715,12 @@'a%sd',concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -763,27 +763,27 @@WHERE equals(person.team_id, 99999)GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -826,27 +826,27 @@WHERE equals(person.team_id, 99999)GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -968,12 +968,12 @@events.distinct_id AS distinct_id,events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -997,13 +997,13 @@events.distinct_id AS distinct_id,events.distinct_id AS distinct_idFROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESCLIMIT 101OFFSET 0 SETTINGS readonly=2,max_execution_time=60,@@ -1027,12 +1027,12 @@events.distinct_id AS distinct_id,concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -1055,12 +1055,12 @@SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`,events.event AS eventFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -1133,14 +1133,14 @@AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}'), toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`,events.event AS eventFROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY tuple(events.uuid, events.event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null'- AND NOT (kv.2 = '[]'- AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}'), toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY tuple(events.uuid, events.event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null'+ AND NOT (kv.2 = '[]'+ AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}'), toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY tuple(events.uuid, events.event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null'AND NOT (kv.2 = '[]'AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}'), toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) ASC@@ -1215,12 +1215,12 @@events.distinct_id AS distinct_id,concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key)))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(properties.key), NULL, if(startsWith(dynamicType(properties.key), 'DateTime'), replaceOne(toString(properties.key), ' ', 'T'), if(or(startsWith(dynamicType(properties.key), 'Array'), startsWith(dynamicType(properties.key), 'Map'), startsWith(dynamicType(properties.key), 'Tuple')), toJSONString(properties.key), toString(properties.key))))))`FROM events_json AS events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events_json AS events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))- ORDER BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))) ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))+ ORDER BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))) ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))ORDER BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(startsWith(dynamicType(events.properties.key), 'DateTime'), replaceOne(toString(events.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.key), 'Array'), startsWith(dynamicType(events.properties.key), 'Map'), startsWith(dynamicType(events.properties.key), 'Tuple')), toJSONString(events.properties.key), toString(events.properties.key))))) ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambrindex 2717a1799d4f..4db2dd15ffde 100644--- a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr+++ b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr@@ -141,10 +141,10 @@'''SELECT DISTINCT session_replay_events.session_id AS session_idFROM session_replay_events- WHERE and(equals(session_replay_events.team_id, 99999), in(session_replay_events.session_id,- (SELECT events.`$session_id` AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%example.com%'), 0)))))+ WHERE and(equals(session_replay_events.team_id, 99999), globalIn(session_replay_events.session_id,+ (SELECT events.`$session_id` AS `$session_id`+ FROM events+ WHERE and(equals(events.team_id, 99999), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%example.com%'), 0)))))ORDER BY session_replay_events.session_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,diff --git a/posthog/hogql/database/schema/test/test_groups_join_prefilter.py b/posthog/hogql/database/schema/test/test_groups_join_prefilter.pyindex 54a73b06c8e3..e871ec1c5d7e 100644--- a/posthog/hogql/database/schema/test/test_groups_join_prefilter.py+++ b/posthog/hogql/database/schema/test/test_groups_join_prefilter.py@@ -49,7 +49,7 @@ class TestGroupsJoinPrefilter(APIBaseTest):# The `$group_0` field reference can be wrapped by the resolver (timestamp clamping# against the GroupTypeMapping created_at, etc.), so we only assert the column ref# appears in the printed SQL — not the exact SELECT prefix.- self.assertIn("in(key,", sql)+ self.assertIn("globalIn(key,", sql)self.assertIn("events.`$group_0`", sql)self.assertIn("FROM events", sql)@@ -61,7 +61,7 @@ class TestGroupsJoinPrefilter(APIBaseTest):"AND timestamp > toDateTime('2026-06-23 02:48:28') ""AND timestamp < toDateTime('2026-06-23 13:32:26')")- self.assertIn("in(key,", sql)+ self.assertIn("globalIn(key,", sql)self.assertIn("events.`$group_0`", sql)def test_skips_filter_when_outer_where_lacks_timestamp(self):diff --git a/posthog/hogql/database/test/test_s3_table.py b/posthog/hogql/database/test/test_s3_table.pyindex f1063eead66b..3b950860d435 100644--- a/posthog/hogql/database/test/test_s3_table.py+++ b/posthog/hogql/database/test/test_s3_table.py@@ -298,7 +298,7 @@ class TestS3Table(BaseTest):self.assertEqual(clickhouse,- f"SELECT events.uuid AS uuid, events.event AS event FROM {self._events_from_sql()} WHERE and(equals(events.team_id, {self.team.pk}), ifNull(globalIn(events.event, (SELECT aapl_stock.Date AS Date FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_1)s) AS aapl_stock)), 0)) LIMIT {MAX_SELECT_RETURNED_ROWS}",+ f"SELECT events.uuid AS uuid, events.event AS event FROM {self._events_from_sql()} WHERE and(equals(events.team_id, {self.team.pk}), globalIn(events.event, (SELECT aapl_stock.Date AS Date FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_1)s) AS aapl_stock))) LIMIT {MAX_SELECT_RETURNED_ROWS}",)def test_s3_build_function_call_without_context(self):diff --git a/posthog/hogql/printer/clickhouse.py b/posthog/hogql/printer/clickhouse.pyindex eca0f141506e..abccc7b9d5f6 100644--- a/posthog/hogql/printer/clickhouse.py+++ b/posthog/hogql/printer/clickhouse.py@@ -749,9 +749,13 @@ class ClickHousePrinter(BasePrinter):return f"ifNull({op}, 1)"return opelif node.op == ast.CompareOperationOp.GlobalIn:- pass+ return opelif node.op == ast.CompareOperationOp.GlobalNotIn:- pass+ # Mirror NotIn above: GLOBAL only changes where the set is built, never the+ # null semantics, so a nullable left keeps rows on NULL exactly like NOT IN.+ if nullable_left and not not_nullable and not in_join_constraint and not in_index_hint:+ return f"ifNull({op}, 1)"+ return opelif node.op == ast.CompareOperationOp.Regex:value_if_both_sides_are_null = Trueelif node.op == ast.CompareOperationOp.NotRegex:diff --git a/posthog/hogql/printer/test/__snapshots__/test_printer.ambr b/posthog/hogql/printer/test/__snapshots__/test_printer.ambrindex 8fb78dcdbc79..abfd78764926 100644--- a/posthog/hogql/printer/test/__snapshots__/test_printer.ambr+++ b/posthog/hogql/printer/test/__snapshots__/test_printer.ambr@@ -3408,7 +3408,7 @@"WITH some_remote_table AS (SELECT e.event AS event, t.id AS id FROM events AS e JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(toString(t.id), e.event) WHERE equals(e.team_id, 99999)) SELECT some_remote_table.event AS event FROM events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000"# ---# name: TestPrinter.test_s3_tables_global_join_with_in_and_property_type_0- 'SELECT events.event AS event FROM events WHERE and(equals(events.team_id, 99999), ifNull(globalIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), \'\'), \'null\'), \'^"|"$\', \'\'), (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_1_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, \'Parquet\', %(hogql_val_2)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table)), 0)) LIMIT 50000'+ 'SELECT events.event AS event FROM events WHERE and(equals(events.team_id, 99999), globalIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), \'\'), \'null\'), \'^"|"$\', \'\'), (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_1_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, \'Parquet\', %(hogql_val_2)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table))) LIMIT 50000'# ---# name: TestPrinter.test_s3_tables_global_join_with_in_and_property_type_1'SELECT events.event AS event FROM events WHERE and(equals(events.team_id, 99999), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), \'\'), \'null\'), \'^"|"$\', \'\'), (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_1_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, \'Parquet\', %(hogql_val_2)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table))) LIMIT 50000'diff --git a/posthog/hogql/printer/test/test_printer.py b/posthog/hogql/printer/test/test_printer.pyindex 39205b99ee0a..5190f60c9268 100644--- a/posthog/hogql/printer/test/test_printer.py+++ b/posthog/hogql/printer/test/test_printer.py@@ -4271,7 +4271,7 @@ class TestPrinter(BaseTest):# Should contain subquery with argMax for deduplication# String literals are parameterized, so check for structure insteadself.assertIn("argMax", printed)- self.assertIn("in(events.uuid", printed)+ self.assertIn("globalIn(events.uuid", printed)self.assertIn("SELECT argMax(events.uuid", printed)self.assertIn(f"FROM {self._events_table_ref()} WHERE", printed)self.assertIn("GROUP BY", printed)@@ -4843,12 +4843,46 @@ class TestPrinter(BaseTest):)assert expected in printed, f"expected {expected} in:\n{printed}"- def test_events_in_subquery_not_promoted(self):- # Non-sessions case: no cross-cluster hazard, keep plain in.- printed = self._select(- "SELECT uuid FROM events WHERE event IN (SELECT event FROM events WHERE timestamp > now() - toIntervalDay(1))"- )+ @parameterized.expand(+ [+ (+ "in_events_subquery",+ "SELECT uuid FROM events WHERE event IN (SELECT event FROM events WHERE timestamp > now() - toIntervalDay(1))",+ "globalIn(",+ ),+ (+ "not_in_events_subquery",+ "SELECT event FROM events WHERE person_id NOT IN (SELECT person_id FROM events WHERE event = 'signup')",+ "globalNotIn(",+ ),+ (+ "nested_events_subquery",+ "SELECT event FROM events WHERE distinct_id IN (SELECT distinct_id FROM (SELECT distinct_id FROM events WHERE event = 'signup'))",+ "globalIn(",+ ),+ (+ "nullable_left_not_in_keeps_rows_on_null",+ "SELECT event FROM events WHERE nullIf(event, '') NOT IN (SELECT event FROM events WHERE event = 'signup')",+ "ifNull(globalNotIn(",+ ),+ ]+ )+ def test_sharded_in_subqueries_promoted_to_global(self, _name, select, expected):+ # A per-shard re-executed IN-subquery over a sharded table costs shard-count times+ # the subquery; GLOBAL IN builds the set once and ships it.+ printed = self._select(select)+ assert expected in printed, f"expected {expected} in:\n{printed}"++ @parameterized.expand(+ [+ ("non_sharded_subquery", "SELECT event FROM events WHERE person_id IN (SELECT id FROM persons)"),+ ("constant_tuple", "SELECT event FROM events WHERE event IN ('signup', 'login')"),+ ]+ )+ def test_non_sharded_in_right_hand_sides_stay_plain(self, _name, select):+ printed = self._select(select)assert "globalIn" not in printed, f"did not expect globalIn in:\n{printed}"+ assert "globalNotIn" not in printed, f"did not expect globalNotIn in:\n{printed}"@parameterized.expand([diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.pyindex 3f0dadf874a3..58968ccdecbd 100644--- a/posthog/hogql/resolver.py+++ b/posthog/hogql/resolver.py@@ -95,6 +95,21 @@ def _string_constants(node: ast.Expr) -> list[ast.Constant]:return []+class _ShardedTableFinder(TraversingVisitor):+ def __init__(self) -> None:+ self.found = False++ def visit_table_type(self, node: ast.TableType) -> None:+ if isinstance(node.table, EventsTable):+ self.found = True+++def _select_reads_sharded_table(node: ast.Expr) -> bool:+ finder = _ShardedTableFinder()+ finder.visit(node)+ return finder.found++EMPTY_SCOPE = ast.SelectQueryType()type PostgresKeywordType = type[ast.DateType] | type[ast.DateTimeType]@@ -2542,6 +2557,19 @@ class Resolver(CloningVisitor):else:node.op = ast.CompareOperationOp.GlobalNotIn+ # An IN-subquery reading a sharded table re-executes on every shard of a distributed+ # outer scan, multiplying its cost by the shard count. GLOBAL IN builds the set once+ # on the initiator and ships it to the shards, returning the same rows.+ if (+ (node.op == ast.CompareOperationOp.In or node.op == ast.CompareOperationOp.NotIn)+ and isinstance(node.right, (ast.SelectQuery, ast.SelectSetQuery))+ and _select_reads_sharded_table(node.right)+ ):+ if node.op == ast.CompareOperationOp.In:+ node.op = ast.CompareOperationOp.GlobalIn+ else:+ node.op = ast.CompareOperationOp.GlobalNotIn+return nodedef _raise_on_invalid_uuid_literal(self, node: ast.CompareOperation) -> None:diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambrindex 53f0d1e658c9..11f8b2b81b9d 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr@@ -107,6 +107,114 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsUDF.test_timezones_trends[new_events_schema.1]+ '''+ SELECT fill.entrance_period_start AS entrance_period_start,+ countIf(ifNull(notEquals(data.success_bool, 0), 1)) AS reached_from_step_count,+ countIf(ifNull(equals(data.success_bool, 1), 0)) AS reached_to_step_count,+ if(greater(reached_from_step_count, 0), round(multiply(divide(reached_to_step_count, reached_from_step_count), 100), 2), 0) AS conversion_rate,+ data.breakdown AS prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'US/Pacific')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'US/Pacific'), 'US/Pacific') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'US/Pacific') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort') AS data+ RIGHT OUTER JOIN+ (SELECT plus(toStartOfDay(assumeNotNull(toDateTime('2021-04-30 00:00:00', 'US/Pacific'))), toIntervalDay(period_offsets.number)) AS entrance_period_start+ FROM numbers(plus(dateDiff('day', toStartOfDay(assumeNotNull(toDateTime('2021-04-30 00:00:00', 'US/Pacific'))), toStartOfDay(assumeNotNull(toDateTime('2021-05-07 23:59:59', 'US/Pacific')))), 1)) AS period_offsets) AS fill ON equals(data.entrance_period_start, fill.entrance_period_start)+ GROUP BY entrance_period_start,+ data.breakdown+ ORDER BY entrance_period_start ASC+ LIMIT 1000 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelTrendsUDF.test_timezones_trends[new_events_schema]+ '''+ SELECT fill.entrance_period_start AS entrance_period_start,+ countIf(ifNull(notEquals(data.success_bool, 0), 1)) AS reached_from_step_count,+ countIf(ifNull(equals(data.success_bool, 1), 0)) AS reached_to_step_count,+ if(greater(reached_from_step_count, 0), round(multiply(divide(reached_to_step_count, reached_from_step_count), 100), 2), 0) AS conversion_rate,+ data.breakdown AS prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort') AS data+ RIGHT OUTER JOIN+ (SELECT plus(toStartOfDay(assumeNotNull(toDateTime('2021-04-30 00:00:00', 'UTC'))), toIntervalDay(period_offsets.number)) AS entrance_period_start+ FROM numbers(plus(dateDiff('day', toStartOfDay(assumeNotNull(toDateTime('2021-04-30 00:00:00', 'UTC'))), toStartOfDay(assumeNotNull(toDateTime('2021-05-07 23:59:59', 'UTC')))), 1)) AS period_offsets) AS fill ON equals(data.entrance_period_start, fill.entrance_period_start)+ GROUP BY entrance_period_start,+ data.breakdown+ ORDER BY entrance_period_start ASC+ LIMIT 1000 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelTrendsUDF.test_week_interval'''SELECT fill.entrance_period_start AS entrance_period_start,@@ -214,3 +322,110 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsUDF.test_week_interval[new_events_schema.1]+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfWeek(timestamp, 0), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 3, 3, 604800, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), 0))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelTrendsUDF.test_week_interval[new_events_schema]+ '''+ SELECT fill.entrance_period_start AS entrance_period_start,+ countIf(ifNull(notEquals(data.success_bool, 0), 1)) AS reached_from_step_count,+ countIf(ifNull(equals(data.success_bool, 1), 0)) AS reached_to_step_count,+ if(greater(reached_from_step_count, 0), round(multiply(divide(reached_to_step_count, reached_from_step_count), 100), 2), 0) AS conversion_rate,+ data.breakdown AS prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfWeek(timestamp, 0), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 3, 3, 604800, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort') AS data+ RIGHT OUTER JOIN+ (SELECT plus(toStartOfWeek(assumeNotNull(toDateTime('2021-05-01 00:00:00', 'UTC')), 0), toIntervalWeek(period_offsets.number)) AS entrance_period_start+ FROM numbers(plus(dateDiff('week', toStartOfWeek(assumeNotNull(toDateTime('2021-05-01 00:00:00', 'UTC')), 0), toStartOfWeek(assumeNotNull(toDateTime('2021-05-07 23:59:59', 'UTC')), 0)), 1)) AS period_offsets) AS fill ON equals(data.entrance_period_start, fill.entrance_period_start)+ GROUP BY entrance_period_start,+ data.breakdown+ ORDER BY entrance_period_start ASC+ LIMIT 1000 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_actors.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_actors.ambrindex 891f81ec750f..ebf9a314476b 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_actors.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_actors.ambr@@ -164,6 +164,171 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_filters_by_breakdown[new_events_schema.1]+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,+ arrayJoin(aggregate_funnel_array_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2,+ [ifNull(toString(e.properties.`$browser`), '')] AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0), equals(arrayFlatten(array(breakdown)), arrayFlatten(array(['Safari']))))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_filters_by_breakdown[new_events_schema.2]+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,+ arrayJoin(aggregate_funnel_array_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2,+ [ifNull(toString(e.properties.`$browser`), '')] AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_filters_by_breakdown[new_events_schema]+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,+ arrayJoin(aggregate_funnel_array_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2,+ [ifNull(toString(e.properties.`$browser`), '')] AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0), equals(arrayFlatten(array(breakdown)), arrayFlatten(array(['Chrome']))))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelTrendsActors.test_funnel_trend_persons_returns_recording_when_converting_step_has_no_session_id'''SELECT source.id,@@ -249,6 +414,67 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_returns_recording_when_converting_step_has_no_session_id[new_events_schema]+ '''+ SELECT source.id,+ source.id AS id,+ source.matching_events AS matching_events+ FROM+ (SELECT aggregation_target AS actor_id,+ matching_events AS matching_events,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 2, 3, 1209600, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`, arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)]))) AS user_events,+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,+ arrayFilter(e -> and(notEquals(e.3, ''), greater(length(e.5), 0), lessOrEquals(e.1, (user_events_map[af_tuple.4]).1)), arraySort(e -> e.1, user_events)) AS session_events,+ [if(greater(length(session_events), 0), session_events[-1], user_events_map[af_tuple.4])] AS matching_events,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelTrendsActors.test_funnel_trend_persons_returns_recordings'''SELECT source.id,@@ -334,6 +560,67 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_returns_recordings[new_events_schema]+ '''+ SELECT source.id,+ source.id AS id,+ source.matching_events AS matching_events+ FROM+ (SELECT aggregation_target AS actor_id,+ matching_events AS matching_events,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 2, 3, 1209600, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`, arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)]))) AS user_events,+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,+ arrayFilter(e -> and(notEquals(e.3, ''), greater(length(e.5), 0), lessOrEquals(e.1, (user_events_map[af_tuple.4]).1)), arraySort(e -> e.1, user_events)) AS session_events,+ [if(greater(length(session_events), 0), session_events[-1], user_events_map[af_tuple.4])] AS matching_events,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelTrendsActors.test_funnel_trend_persons_with_drop_off'''SELECT source.id,@@ -419,6 +706,67 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_with_drop_off[new_events_schema]+ '''+ SELECT source.id,+ source.id AS id,+ source.matching_events AS matching_events+ FROM+ (SELECT aggregation_target AS actor_id,+ matching_events AS matching_events,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`, arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)]))) AS user_events,+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,+ arrayFilter(e -> and(notEquals(e.3, ''), greater(length(e.5), 0), lessOrEquals(e.1, (user_events_map[af_tuple.4]).1)), arraySort(e -> e.1, user_events)) AS session_events,+ [if(greater(length(session_events), 0), session_events[-1], user_events_map[af_tuple.4])] AS matching_events,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(notEquals(success_bool, 1), 1), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelTrendsActors.test_funnel_trend_persons_with_no_to_step'''SELECT source.id,@@ -504,3 +852,64 @@use_hive_partitioning=0'''# ---+# name: TestFunnelTrendsActors.test_funnel_trend_persons_with_no_to_step[new_events_schema]+ '''+ SELECT source.id,+ source.id AS id,+ source.matching_events AS matching_events+ FROM+ (SELECT aggregation_target AS actor_id,+ matching_events AS matching_events,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), toUInt64(toDateTime(toStartOfDay(timestamp), 'UTC')), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [''] AS prop,+ arrayJoin(aggregate_funnel_trends(1, 3, 3, 1209600, 'first_touch', 'ordered', prop, events_array)) AS af_tuple,+ toTimeZone(toDateTime(toUInt64(af_tuple.1), 'UTC'), 'UTC') AS entrance_period_start,+ af_tuple.2 AS success_bool,+ af_tuple.3 AS breakdown,+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`, arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)]))) AS user_events,+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,+ arrayFilter(e -> and(notEquals(e.3, ''), greater(length(e.5), 0), lessOrEquals(e.1, (user_events_map[af_tuple.4]).1)), arraySort(e -> e.1, user_events)) AS session_events,+ [if(greater(length(session_events), 0), session_events[-1], user_events_map[af_tuple.4])] AS matching_events,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'step one'), 1, 0) AS step_0,+ if(equals(e.event, 'step two'), 1, 0) AS step_1,+ if(equals(e.event, 'step three'), 1, 0) AS step_2+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target SETTINGS date_time_output_format='iso',+ date_time_input_format='best_effort')+ WHERE and(ifNull(equals(success_bool, 1), 0), ifNull(equals(entrance_period_start, toDateTime64('today', 6, 'UTC')), 0))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambrindex b16027a7ca73..2658837be0fa 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr@@ -78,6 +78,85 @@use_hive_partitioning=0'''# ---+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events[new_events_schema]+ '''+ SELECT sum(step_1) AS step_1,+ sum(step_2) AS step_2,+ sum(step_3) AS step_3,+ arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,+ groupArray(row_number) AS row_number,+ final_prop AS final_prop+ FROM+ (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,+ groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,+ rowNumberInAllBlocks() AS row_number,+ if(less(row_number, 25), breakdown, 'Other') AS final_prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,+ arrayJoin(aggregate_funnel(3, 1209600, 'first_touch', 'unordered', prop, [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), ifNull(equals(x.3, x_before.3), isNull(x.3)+ and isNull(x_before.3)), ifNull(equals(x.3, x_after.3), isNull(x.3)+ and isNull(x_after.3)), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ e.`$group_0` AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'play movie'), 1, 0) AS step_1,+ if(equals(e.event, 'buy'), 1, 0) AS step_2,+ ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry,+ groups.group_type_index AS index,+ groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up')), and(notEquals(toString(aggregation_target), ''), isNotNull(aggregation_target))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ GROUP BY breakdown+ ORDER BY step_3 DESC,+ step_2 DESC,+ step_1 DESC)+ GROUP BY final_prop+ ORDER BY step_3 DESC,+ step_2 DESC,+ step_1 DESC+ LIMIT 26 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group'''SELECT sum(step_1) AS step_1,@@ -91,14 +170,293 @@groupArray(row_number) AS row_number,final_prop AS final_propFROM- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,- groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,- rowNumberInAllBlocks() AS row_number,- if(less(row_number, 25), breakdown, 'Other') AS final_prop+ (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,+ groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,+ rowNumberInAllBlocks() AS row_number,+ if(less(row_number, 25), breakdown, 'Other') AS final_prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,+ arrayJoin(aggregate_funnel(3, 1209600, 'first_touch', 'unordered', prop, [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), ifNull(equals(x.3, x_before.3), isNull(x.3)+ and isNull(x_before.3)), ifNull(equals(x.3, x_after.3), isNull(x.3)+ and isNull(x_after.3)), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'play movie'), 1, 0) AS step_1,+ if(equals(e.event, 'buy'), 1, 0) AS step_2,+ ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,+ prop_basic AS prop+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry,+ groups.group_type_index AS index,+ groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ GROUP BY breakdown+ ORDER BY step_3 DESC,+ step_2 DESC,+ step_1 DESC)+ GROUP BY final_prop+ ORDER BY step_3 DESC,+ step_2 DESC,+ step_1 DESC+ LIMIT 26 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.1+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,+ arrayJoin(aggregate_funnel(3, 1209600, 'first_touch', 'unordered', prop, [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), ifNull(equals(x.3, x_before.3), isNull(x.3)+ and isNull(x_before.3)), ifNull(equals(x.3, x_after.3), isNull(x.3)+ and isNull(x_after.3)), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'play movie'), 1, 0) AS step_1,+ if(equals(e.event, 'buy'), 1, 0) AS step_2,+ ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,+ prop_basic AS prop+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry,+ groups.group_type_index AS index,+ groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ WHERE and(bitTest(steps_bitfield, 0), equals(arrayFlatten(array(breakdown)), arrayFlatten(array('finance'))))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.2+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,+ arrayJoin(aggregate_funnel(3, 1209600, 'first_touch', 'unordered', prop, [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), ifNull(equals(x.3, x_before.3), isNull(x.3)+ and isNull(x_before.3)), ifNull(equals(x.3, x_after.3), isNull(x.3)+ and isNull(x_after.3)), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'play movie'), 1, 0) AS step_1,+ if(equals(e.event, 'buy'), 1, 0) AS step_2,+ ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,+ prop_basic AS prop+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry,+ groups.group_type_index AS index,+ groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ WHERE and(bitTest(steps_bitfield, 1), equals(arrayFlatten(array(breakdown)), arrayFlatten(array('finance'))))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.3+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS id+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,+ arrayJoin(aggregate_funnel(3, 1209600, 'first_touch', 'unordered', prop, [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), ifNull(equals(x.3, x_before.3), isNull(x.3)+ and isNull(x_before.3)), ifNull(equals(x.3, x_after.3), isNull(x.3)+ and isNull(x_after.3)), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'play movie'), 1, 0) AS step_1,+ if(equals(e.event, 'buy'), 1, 0) AS step_2,+ ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,+ prop_basic AS prop+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry,+ groups.group_type_index AS index,+ groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ WHERE and(bitTest(steps_bitfield, 0), equals(arrayFlatten(array(breakdown)), arrayFlatten(array('technology'))))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.4+ '''+ SELECT source.id,+ source.id AS id+ FROM+ (SELECT aggregation_target AS actor_id,+ actor_id AS idFROM(SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,[argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,@@ -141,21 +499,18 @@WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))GROUP BY aggregation_targetHAVING ifNull(greaterOrEquals(step_reached, 0), 0))- GROUP BY breakdown- ORDER BY step_3 DESC,- step_2 DESC,- step_1 DESC)- GROUP BY final_prop- ORDER BY step_3 DESC,- step_2 DESC,- step_1 DESC- LIMIT 26 SETTINGS join_algorithm='auto',+ WHERE and(bitTest(steps_bitfield, 1), equals(arrayFlatten(array(breakdown)), arrayFlatten(array('technology'))))+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto') AS source+ ORDER BY source.id ASC+ LIMIT 101+ OFFSET 0 SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto',readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=23622320128,+ max_bytes_before_external_group_by=0,transform_null_in=1,optimize_min_equality_disjunction_chain_length=4294967295,optimize_rewrite_aggregate_function_with_if=0,@@ -164,7 +519,7 @@use_hive_partitioning=0'''# ----# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.1+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group[new_events_schema.1]'''SELECT source.id,source.id AS id@@ -194,7 +549,7 @@if(equals(e.event, 'buy'), 1, 0) AS step_2,ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,prop_basic AS prop- FROM events AS e+ FROM events_json AS eLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -233,7 +588,7 @@use_hive_partitioning=0'''# ----# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.2+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group[new_events_schema.2]'''SELECT source.id,source.id AS id@@ -263,7 +618,7 @@if(equals(e.event, 'buy'), 1, 0) AS step_2,ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,prop_basic AS prop- FROM events AS e+ FROM events_json AS eLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -302,7 +657,7 @@use_hive_partitioning=0'''# ----# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.3+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group[new_events_schema.3]'''SELECT source.id,source.id AS id@@ -332,7 +687,7 @@if(equals(e.event, 'buy'), 1, 0) AS step_2,ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,prop_basic AS prop- FROM events AS e+ FROM events_json AS eLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -371,7 +726,7 @@use_hive_partitioning=0'''# ----# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group.4+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group[new_events_schema.4]'''SELECT source.id,source.id AS id@@ -401,7 +756,7 @@if(equals(e.event, 'buy'), 1, 0) AS step_2,ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,prop_basic AS prop- FROM events AS e+ FROM events_json AS eLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -440,6 +795,92 @@use_hive_partitioning=0'''# ---+# name: TestFunnelUnorderedGroupBreakdown.test_funnel_breakdown_group[new_events_schema]+ '''+ SELECT sum(step_1) AS step_1,+ sum(step_2) AS step_2,+ sum(step_3) AS step_3,+ arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,+ groupArray(row_number) AS row_number,+ final_prop AS final_prop+ FROM+ (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,+ groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,+ rowNumberInAllBlocks() AS row_number,+ if(less(row_number, 25), breakdown, 'Other') AS final_prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, ifNull(prop_basic, ''), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1), multiply(3, step_2)])))) AS events_array,+ [argMinIf(prop_basic, timestamp, isNotNull(prop_basic))] AS prop,+ arrayJoin(aggregate_funnel(3, 1209600, 'first_touch', 'unordered', prop, [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), ifNull(equals(x.3, x_before.3), isNull(x.3)+ and isNull(x_before.3)), ifNull(equals(x.3, x_after.3), isNull(x.3)+ and isNull(x_after.3)), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'play movie'), 1, 0) AS step_1,+ if(equals(e.event, 'buy'), 1, 0) AS step_2,+ ifNull(toString(e__group_0.properties___industry), '') AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry,+ groups.group_type_index AS index,+ groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'play movie', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ GROUP BY breakdown+ ORDER BY step_3 DESC,+ step_2 DESC,+ step_1 DESC)+ GROUP BY final_prop+ ORDER BY step_3 DESC,+ step_2 DESC,+ step_1 DESC+ LIMIT 26 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelUnorderedStepsBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen'''SELECT sum(step_1) AS step_1,@@ -508,6 +949,74 @@use_hive_partitioning=0'''# ---+# name: TestFunnelUnorderedStepsBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen[new_events_schema]+ '''+ SELECT sum(step_1) AS step_1,+ sum(step_2) AS step_2,+ arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,+ groupArray(row_number) AS row_number,+ final_prop AS final_prop+ FROM+ (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,+ groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,+ rowNumberInAllBlocks() AS row_number,+ if(less(row_number, 25), breakdown, ['Other']) AS final_prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,+ argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,+ arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'unordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(and(equals(e.event, 'buy'), ifNull(equals(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(e.properties.`$version`), NULL, if(startsWith(dynamicType(e.properties.`$version`), 'DateTime'), replaceOne(toString(e.properties.`$version`), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.`$version`), 'Array'), startsWith(dynamicType(e.properties.`$version`), 'Map'), startsWith(dynamicType(e.properties.`$version`), 'Tuple')), toJSONString(e.properties.`$version`), toString(e.properties.`$version`))))), 'xyz'), 0)), 1, 0) AS step_1,+ [ifNull(toString(e.properties.`$browser`), '')] AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ GROUP BY breakdown+ ORDER BY step_2 DESC,+ step_1 DESC)+ GROUP BY final_prop+ ORDER BY step_2 DESC,+ step_1 DESC+ LIMIT 26 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestFunnelUnorderedStepsBreakdown.test_funnel_step_multiple_breakdown_snapshot'''SELECT sum(step_1) AS step_1,@@ -576,3 +1085,71 @@use_hive_partitioning=0'''# ---+# name: TestFunnelUnorderedStepsBreakdown.test_funnel_step_multiple_breakdown_snapshot[new_events_schema]+ '''+ SELECT sum(step_1) AS step_1,+ sum(step_2) AS step_2,+ arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,+ groupArray(row_number) AS row_number,+ final_prop AS final_prop+ FROM+ (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,+ countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,+ groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,+ rowNumberInAllBlocks() AS row_number,+ if(less(row_number, 25), breakdown, ['Other']) AS final_prop+ FROM+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,+ argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,+ arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'unordered', [if(empty(prop), ['', ''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,+ af_tuple.1 AS step_reached,+ plus(af_tuple.1, 1) AS steps,+ af_tuple.2 AS breakdown,+ af_tuple.3 AS timings,+ af_tuple.5 AS steps_bitfield,+ aggregation_target AS aggregation_target+ FROM+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,+ if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,+ e.uuid AS uuid,+ e.`$session_id` AS `$session_id`,+ e.`$window_id` AS `$window_id`,+ if(equals(e.event, 'sign up'), 1, 0) AS step_0,+ if(equals(e.event, 'buy'), 1, 0) AS step_1,+ [ifNull(toString(e.properties.`$browser`), ''), ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(e.properties.`$version`), NULL, if(startsWith(dynamicType(e.properties.`$version`), 'DateTime'), replaceOne(toString(e.properties.`$version`), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.`$version`), 'Array'), startsWith(dynamicType(e.properties.`$version`), 'Map'), startsWith(dynamicType(e.properties.`$version`), 'Tuple')), toJSONString(e.properties.`$version`), toString(e.properties.`$version`)))))), '')] AS prop_basic,+ prop_basic AS prop+ FROM events_json AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('buy', 'sign up'))), or(equals(step_0, 1), equals(step_1, 1))))+ GROUP BY aggregation_target+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))+ GROUP BY breakdown+ ORDER BY step_2 DESC,+ step_1 DESC)+ GROUP BY final_prop+ ORDER BY step_2 DESC,+ step_1 DESC+ LIMIT 26 SETTINGS join_algorithm='auto',+ readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/hogql_queries/insights/lifecycle/test/__snapshots__/test_lifecycle_query_runner.ambr b/posthog/hogql_queries/insights/lifecycle/test/__snapshots__/test_lifecycle_query_runner.ambrindex 437e9502f7e4..a7f7b1a70944 100644--- a/posthog/hogql_queries/insights/lifecycle/test/__snapshots__/test_lifecycle_query_runner.ambr+++ b/posthog/hogql_queries/insights/lifecycle/test/__snapshots__/test_lifecycle_query_runner.ambr@@ -93,6 +93,90 @@use_hive_partitioning=0'''# ---+# name: TestLifecycleQueryRunner.test_cohort_filter[new_events_schema]+ '''+ SELECT groupArray(start_of_period) AS date,+ groupArray(counts) AS total,+ status AS status+ FROM+ (SELECT if(ifNull(equals(status, 'dormant'), 0), negate(sum(counts)), negate(negate(sum(counts)))) AS counts,+ start_of_period AS start_of_period,+ status AS status+ FROM+ (SELECT periods.start_of_period AS start_of_period,+ 0 AS counts,+ sec.status AS status+ FROM+ (SELECT minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(numbers.number)) AS start_of_period+ FROM numbers(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(plus(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(1)))) AS numbers) AS periods+ CROSS JOIN+ (SELECT status+ FROM+ (SELECT 1) ARRAY+ JOIN ['new', 'returning', 'resurrecting', 'dormant'] AS status) AS sec+ ORDER BY sec.status ASC,+ start_of_period ASC+ UNION ALL SELECT start_of_period AS start_of_period,+ count(DISTINCT actor_id) AS counts,+ status AS status+ FROM+ (SELECT min(events__person.created_at) AS created_at,+ arraySort(groupUniqArray(toStartOfInterval(toTimeZone(events.timestamp, 'UTC'), toIntervalDay(1)))) AS all_activity,+ arrayPopBack(arrayPushFront(all_activity, toStartOfInterval(created_at, toIntervalDay(1)))) AS previous_activity,+ arrayPopFront(arrayPushBack(all_activity, toStartOfInterval(toDateTime('1970-01-01 00:00:00', 'UTC'), toIntervalDay(1)))) AS following_activity,+ arrayMap((previous, current, index) -> if(ifNull(equals(previous, current), isNull(previous)+ and isNull(current)), 'new', if(and(ifNull(equals(minus(toTimeZone(current, 'UTC'), toIntervalDay(1)), previous), isNull(minus(toTimeZone(current, 'UTC'), toIntervalDay(1)))+ and isNull(previous)), ifNull(notEquals(index, 1), 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status,+ arrayMap((current, next) -> if(ifNull(equals(plus(toTimeZone(current, 'UTC'), toIntervalDay(1)), toTimeZone(next, 'UTC')), isNull(plus(toTimeZone(current, 'UTC'), toIntervalDay(1)))+ and isNull(toTimeZone(next, 'UTC'))), '', 'dormant'), all_activity, following_activity) AS dormant_status,+ arrayMap(x -> plus(toTimeZone(x, 'UTC'), toIntervalDay(1)), arrayFilter((current, is_dormant) -> ifNull(equals(is_dormant, 'dormant'), 0), all_activity, dormant_status)) AS dormant_periods,+ arrayMap(x -> 'dormant', dormant_periods) AS dormant_label,+ arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat,+ arrayJoin(temp_concat) AS period_status_pairs,+ period_status_pairs.1 AS start_of_period,+ period_status_pairs.2 AS status,+ if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,+ person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(notEquals(events.properties.`$process_person_profile`, 'false'), 1), greaterOrEquals(events.timestamp, minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(1))), less(events.timestamp, plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(1))), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),+ (SELECT cohortpeople.person_id AS person_id+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0)))), equals(events.event, '$pageview'))+ GROUP BY actor_id)+ GROUP BY start_of_period,+ status)+ WHERE and(lessOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1))), greaterOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1))))+ GROUP BY start_of_period,+ status+ ORDER BY start_of_period ASC)+ GROUP BY status+ LIMIT 100 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestLifecycleQueryRunner.test_sampling'''SELECT groupArray(start_of_period) AS date,@@ -174,6 +258,87 @@use_hive_partitioning=0'''# ---+# name: TestLifecycleQueryRunner.test_sampling[new_events_schema]+ '''+ SELECT groupArray(start_of_period) AS date,+ groupArray(round(multiply(counts, divide(1, 0.1)))) AS total,+ status AS status+ FROM+ (SELECT if(ifNull(equals(status, 'dormant'), 0), negate(sum(counts)), negate(negate(sum(counts)))) AS counts,+ start_of_period AS start_of_period,+ status AS status+ FROM+ (SELECT periods.start_of_period AS start_of_period,+ 0 AS counts,+ sec.status AS status+ FROM+ (SELECT minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(numbers.number)) AS start_of_period+ FROM numbers(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(plus(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(1)))) AS numbers) AS periods+ CROSS JOIN+ (SELECT status+ FROM+ (SELECT 1) ARRAY+ JOIN ['new', 'returning', 'resurrecting', 'dormant'] AS status) AS sec+ ORDER BY sec.status ASC,+ start_of_period ASC+ UNION ALL SELECT start_of_period AS start_of_period,+ count(DISTINCT actor_id) AS counts,+ status AS status+ FROM+ (SELECT min(events__person.created_at) AS created_at,+ arraySort(groupUniqArray(toStartOfInterval(toTimeZone(events.timestamp, 'UTC'), toIntervalDay(1)))) AS all_activity,+ arrayPopBack(arrayPushFront(all_activity, toStartOfInterval(created_at, toIntervalDay(1)))) AS previous_activity,+ arrayPopFront(arrayPushBack(all_activity, toStartOfInterval(toDateTime('1970-01-01 00:00:00', 'UTC'), toIntervalDay(1)))) AS following_activity,+ arrayMap((previous, current, index) -> if(ifNull(equals(previous, current), isNull(previous)+ and isNull(current)), 'new', if(and(ifNull(equals(minus(toTimeZone(current, 'UTC'), toIntervalDay(1)), previous), isNull(minus(toTimeZone(current, 'UTC'), toIntervalDay(1)))+ and isNull(previous)), ifNull(notEquals(index, 1), 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status,+ arrayMap((current, next) -> if(ifNull(equals(plus(toTimeZone(current, 'UTC'), toIntervalDay(1)), toTimeZone(next, 'UTC')), isNull(plus(toTimeZone(current, 'UTC'), toIntervalDay(1)))+ and isNull(toTimeZone(next, 'UTC'))), '', 'dormant'), all_activity, following_activity) AS dormant_status,+ arrayMap(x -> plus(toTimeZone(x, 'UTC'), toIntervalDay(1)), arrayFilter((current, is_dormant) -> ifNull(equals(is_dormant, 'dormant'), 0), all_activity, dormant_status)) AS dormant_periods,+ arrayMap(x -> 'dormant', dormant_periods) AS dormant_label,+ arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat,+ arrayJoin(temp_concat) AS period_status_pairs,+ period_status_pairs.1 AS start_of_period,+ period_status_pairs.2 AS status,+ if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id+ FROM events_json AS events SAMPLE 0.1+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,+ person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(notEquals(events.properties.`$process_person_profile`, 'false'), 1), greaterOrEquals(events.timestamp, minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(1))), less(events.timestamp, plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(1))), equals(events.event, '$pageview'))+ GROUP BY actor_id)+ GROUP BY start_of_period,+ status)+ WHERE and(lessOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1))), greaterOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1))))+ GROUP BY start_of_period,+ status+ ORDER BY start_of_period ASC)+ GROUP BY status+ LIMIT 100 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestLifecycleQueryRunner.test_timezones'''SELECT groupArray(start_of_period) AS date,@@ -336,3 +501,165 @@use_hive_partitioning=0'''# ---+# name: TestLifecycleQueryRunner.test_timezones[new_events_schema.1]+ '''+ SELECT groupArray(start_of_period) AS date,+ groupArray(counts) AS total,+ status AS status+ FROM+ (SELECT if(ifNull(equals(status, 'dormant'), 0), negate(sum(counts)), negate(negate(sum(counts)))) AS counts,+ start_of_period AS start_of_period,+ status AS status+ FROM+ (SELECT periods.start_of_period AS start_of_period,+ 0 AS counts,+ sec.status AS status+ FROM+ (SELECT minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(numbers.number)) AS start_of_period+ FROM numbers(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'US/Pacific')), toIntervalDay(1)), toStartOfInterval(plus(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1)))) AS numbers) AS periods+ CROSS JOIN+ (SELECT status+ FROM+ (SELECT 1) ARRAY+ JOIN ['new', 'returning', 'resurrecting', 'dormant'] AS status) AS sec+ ORDER BY sec.status ASC,+ start_of_period ASC+ UNION ALL SELECT start_of_period AS start_of_period,+ count(DISTINCT actor_id) AS counts,+ status AS status+ FROM+ (SELECT min(events__person.created_at) AS created_at,+ arraySort(groupUniqArray(toStartOfInterval(toTimeZone(events.timestamp, 'US/Pacific'), toIntervalDay(1)))) AS all_activity,+ arrayPopBack(arrayPushFront(all_activity, toStartOfInterval(created_at, toIntervalDay(1)))) AS previous_activity,+ arrayPopFront(arrayPushBack(all_activity, toStartOfInterval(toDateTime('1970-01-01 00:00:00', 'US/Pacific'), toIntervalDay(1)))) AS following_activity,+ arrayMap((previous, current, index) -> if(ifNull(equals(previous, current), isNull(previous)+ and isNull(current)), 'new', if(and(ifNull(equals(minus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)), previous), isNull(minus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)))+ and isNull(previous)), ifNull(notEquals(index, 1), 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status,+ arrayMap((current, next) -> if(ifNull(equals(plus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)), toTimeZone(next, 'US/Pacific')), isNull(plus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)))+ and isNull(toTimeZone(next, 'US/Pacific'))), '', 'dormant'), all_activity, following_activity) AS dormant_status,+ arrayMap(x -> plus(toTimeZone(x, 'US/Pacific'), toIntervalDay(1)), arrayFilter((current, is_dormant) -> ifNull(equals(is_dormant, 'dormant'), 0), all_activity, dormant_status)) AS dormant_periods,+ arrayMap(x -> 'dormant', dormant_periods) AS dormant_label,+ arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat,+ arrayJoin(temp_concat) AS period_status_pairs,+ period_status_pairs.1 AS start_of_period,+ period_status_pairs.2 AS status,+ if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version) AS created_at,+ person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(notEquals(events.properties.`$process_person_profile`, 'false'), 1), greaterOrEquals(events.timestamp, minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1))), less(events.timestamp, plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1))), equals(events.event, '$pageview'))+ GROUP BY actor_id)+ GROUP BY start_of_period,+ status)+ WHERE and(lessOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific')), toIntervalDay(1))), greaterOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'US/Pacific')), toIntervalDay(1))))+ GROUP BY start_of_period,+ status+ ORDER BY start_of_period ASC)+ GROUP BY status+ LIMIT 100 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestLifecycleQueryRunner.test_timezones[new_events_schema]+ '''+ SELECT groupArray(start_of_period) AS date,+ groupArray(counts) AS total,+ status AS status+ FROM+ (SELECT if(ifNull(equals(status, 'dormant'), 0), negate(sum(counts)), negate(negate(sum(counts)))) AS counts,+ start_of_period AS start_of_period,+ status AS status+ FROM+ (SELECT periods.start_of_period AS start_of_period,+ 0 AS counts,+ sec.status AS status+ FROM+ (SELECT minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(numbers.number)) AS start_of_period+ FROM numbers(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(plus(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(1)))) AS numbers) AS periods+ CROSS JOIN+ (SELECT status+ FROM+ (SELECT 1) ARRAY+ JOIN ['new', 'returning', 'resurrecting', 'dormant'] AS status) AS sec+ ORDER BY sec.status ASC,+ start_of_period ASC+ UNION ALL SELECT start_of_period AS start_of_period,+ count(DISTINCT actor_id) AS counts,+ status AS status+ FROM+ (SELECT min(events__person.created_at) AS created_at,+ arraySort(groupUniqArray(toStartOfInterval(toTimeZone(events.timestamp, 'UTC'), toIntervalDay(1)))) AS all_activity,+ arrayPopBack(arrayPushFront(all_activity, toStartOfInterval(created_at, toIntervalDay(1)))) AS previous_activity,+ arrayPopFront(arrayPushBack(all_activity, toStartOfInterval(toDateTime('1970-01-01 00:00:00', 'UTC'), toIntervalDay(1)))) AS following_activity,+ arrayMap((previous, current, index) -> if(ifNull(equals(previous, current), isNull(previous)+ and isNull(current)), 'new', if(and(ifNull(equals(minus(toTimeZone(current, 'UTC'), toIntervalDay(1)), previous), isNull(minus(toTimeZone(current, 'UTC'), toIntervalDay(1)))+ and isNull(previous)), ifNull(notEquals(index, 1), 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status,+ arrayMap((current, next) -> if(ifNull(equals(plus(toTimeZone(current, 'UTC'), toIntervalDay(1)), toTimeZone(next, 'UTC')), isNull(plus(toTimeZone(current, 'UTC'), toIntervalDay(1)))+ and isNull(toTimeZone(next, 'UTC'))), '', 'dormant'), all_activity, following_activity) AS dormant_status,+ arrayMap(x -> plus(toTimeZone(x, 'UTC'), toIntervalDay(1)), arrayFilter((current, is_dormant) -> ifNull(equals(is_dormant, 'dormant'), 0), all_activity, dormant_status)) AS dormant_periods,+ arrayMap(x -> 'dormant', dormant_periods) AS dormant_label,+ arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat,+ arrayJoin(temp_concat) AS period_status_pairs,+ period_status_pairs.1 AS start_of_period,+ period_status_pairs.2 AS status,+ if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,+ person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(notEquals(events.properties.`$process_person_profile`, 'false'), 1), greaterOrEquals(events.timestamp, minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(1))), less(events.timestamp, plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1)), toIntervalDay(1))), equals(events.event, '$pageview'))+ GROUP BY actor_id)+ GROUP BY start_of_period,+ status)+ WHERE and(lessOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'UTC')), toIntervalDay(1))), greaterOrEquals(start_of_period, toStartOfInterval(assumeNotNull(toDateTime('2020-01-12 00:00:00', 'UTC')), toIntervalDay(1))))+ GROUP BY start_of_period,+ status+ ORDER BY start_of_period ASC)+ GROUP BY status+ LIMIT 100 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse.ambr b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse.ambrindex ddce309c8586..cc6f0421d417 100644--- a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse.ambr+++ b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse.ambr@@ -51,6 +51,58 @@use_hive_partitioning=0'''# ---+# name: TestRetentionDataWarehouse.test_retention_data_warehouse_and_events[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT retention_events.actor_id AS actor_id,+ arrayFlatten(groupArray(retention_events.start_event_timestamps)) AS start_event_timestamps,+ arrayFlatten(groupArray(retention_events.return_event_timestamps)) AS return_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 5)) AS date_range,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 4), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT posthog_test_warehouse_event_mix_signups.person_id AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(posthog_test_warehouse_event_mix_signups.signed_up_at, 'UTC')), and(greaterOrEquals(toTimeZone(posthog_test_warehouse_event_mix_signups.signed_up_at, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(posthog_test_warehouse_event_mix_signups.signed_up_at, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS start_event_timestamps,+ [] AS return_event_timestamps+ FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql_queries.insights.retention.data_warehouse/posthog_test_warehouse_event_mix_signups/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Int64, `person_id` UUID, `signed_up_at` DateTime64(3, \'UTC\')') AS posthog_test_warehouse_event_mix_signups+ GROUP BY actor_id+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ [] AS start_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'paid'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('paid')), equals(events.event, 'paid'))+ GROUP BY actor_id) AS retention_events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS format_csv_allow_double_quotes=1,+ readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestRetentionDataWarehouse.test_retention_data_warehouse_breakdown_by_warehouse_column'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,diff --git a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse_24h_window.ambr b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse_24h_window.ambrindex dcabadec30d8..3c99cba5d0ce 100644--- a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse_24h_window.ambr+++ b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_data_warehouse_24h_window.ambr@@ -48,6 +48,55 @@use_hive_partitioning=0'''# ---+# name: TestRetentionDataWarehouse24hWindow.test_first_time_events_start_dwh_return_24h_window[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT actors_with_t0.actor_id AS actor_id,+ floor(divide(dateDiff('hour', assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), actors_with_t0.t_0), 24)) AS start_interval_index,+ arrayJoin(arrayDistinct(arrayConcat([0], arrayFilter(x -> ifNull(greaterOrEquals(x, 0), 0), groupUniqArray(if(ifNull(greaterOrEquals(return_events.timestamp, actors_with_t0.t_0), 0), floor(divide(dateDiff('hour', actors_with_t0.t_0, return_events.timestamp), 24)), -1)))))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ if(and(greaterOrEquals(minIf(toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$signup')), toStartOfInterval(assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), toIntervalDay(1))), less(minIf(toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$signup')), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), minIf(toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$signup')), NULL) AS t_0+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(events.event, '$signup'))+ GROUP BY actor_id+ HAVING isNotNull(t_0)) AS actors_with_t0+ LEFT JOIN+ (SELECT posthog_test_warehouse_renewals_ft.person_id AS actor_id,+ toTimeZone(posthog_test_warehouse_renewals_ft.occurred_at, 'UTC') AS timestamp+ FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql_queries.insights.retention.data_warehouse_24h_window/posthog_test_warehouse_renewals_ft/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Int64, `person_id` UUID, `occurred_at` DateTime64(3, \'UTC\')') AS posthog_test_warehouse_renewals_ft+ WHERE and(greaterOrEquals(posthog_test_warehouse_renewals_ft.occurred_at, toStartOfInterval(assumeNotNull(toDateTime('2025-01-01 00:00:00', 'UTC')), toIntervalDay(1))), less(posthog_test_warehouse_renewals_ft.occurred_at, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))) AS return_events ON equals(actors_with_t0.actor_id, return_events.actor_id)+ GROUP BY actors_with_t0.actor_id,+ actors_with_t0.t_0) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS format_csv_allow_double_quotes=1,+ readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestRetentionDataWarehouse24hWindow.test_same_table_dwh_start_and_return_24h_window'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,diff --git a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambrindex f1b2cd02db98..706c333103bd 100644--- a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr+++ b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr@@ -909,6 +909,88 @@use_hive_partitioning=0'''# ---+# name: TestRetention.test_day_interval_sampled[new_events_schema.1]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_day_interval_sampled[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestRetention.test_month_interval_with_person_on_events_v2'''@@ -1000,6 +1082,88 @@use_hive_partitioning=0'''# ---+# name: TestRetention.test_month_interval_with_person_on_events_v2[new_events_schema.1]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfMonth(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1)), toIntervalMonth(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfMonth(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_month_interval_with_person_on_events_v2[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfMonth(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1)), toIntervalMonth(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfMonth(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalMonth(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestRetention.test_retention_aggregation_different_events_ignores_start_event_property_value'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,@@ -1118,52 +1282,7 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_aggregation_sum- '''- SELECT actor_activity.start_interval_index AS start_event_matching_interval,- actor_activity.intervals_from_base AS intervals_from_base,- count(DISTINCT actor_activity.actor_id) AS count,- sum(actor_activity.retention_value) AS aggregation_value- FROM- (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,- groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,- groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data,- arrayMap(x -> x.1, _return_event_data) AS return_event_timestamps,- arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,- arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_value- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))- GROUP BY actor_id- HAVING 1) AS actor_activity- GROUP BY start_event_matching_interval,- intervals_from_base- ORDER BY start_event_matching_interval ASC,- intervals_from_base ASC- LIMIT 100000 SETTINGS readonly=2,- max_execution_time=600,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=23622320128,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ----# name: TestRetention.test_retention_aggregation_sum.1+# name: TestRetention.test_retention_aggregation_different_events_ignores_start_event_property_value[new_events_schema.1]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,@@ -1178,16 +1297,20 @@arrayFlatten(groupArray(retention_events._return_event_data)) AS _return_event_data,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)- and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), 0.0), _start_event_data)), arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 8), item.1), 1), 'Int64'), item.2), arrayFilter(x -> or(ifNull(greater(x.1, date_range[plus(start_interval_index, 1)]), 0), and(ifNull(equals(x.1, date_range[plus(start_interval_index, 1)]), isNull(x.1)+ and isNull(date_range[plus(start_interval_index, 1)])), ifNull(greater(x.3, arrayMin(arrayMap(y -> y.3, arrayFilter(z -> ifNull(equals(z.1, date_range[plus(start_interval_index, 1)]), isNull(z.1)+ and isNull(date_range[plus(start_interval_index, 1)])), _start_event_data)))), 0))), _return_event_data))))).1 AS intervals_from_base,arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)- and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_value+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), 0.0), _start_event_data)), arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 8), item.1), 1), 'Int64'), item.2), arrayFilter(x -> or(ifNull(greater(x.1, date_range[plus(start_interval_index, 1)]), 0), and(ifNull(equals(x.1, date_range[plus(start_interval_index, 1)]), isNull(x.1)+ and isNull(date_range[plus(start_interval_index, 1)])), ifNull(greater(x.3, arrayMin(arrayMap(y -> y.3, arrayFilter(z -> ifNull(equals(z.1, date_range[plus(start_interval_index, 1)]), isNull(z.1)+ and isNull(date_range[plus(start_interval_index, 1)])), _start_event_data)))), 0))), _return_event_data))))).2 AS retention_valueFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS start_event_timestamps,+ arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), 0.0, toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'signed_up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS start_event_timestamps,[] AS return_event_timestamps,- groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), 0.0, toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'signed_up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,[] AS _return_event_data- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1195,14 +1318,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), equals(events.event, '$pageview'))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('signed_up')), equals(events.event, 'signed_up'))GROUP BY actor_idUNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,[] AS start_event_timestamps,- arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS return_event_timestamps,+ arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'purchased'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS return_event_timestamps,[] AS _start_event_data,- groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data- FROM events+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'purchased'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1210,7 +1333,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), equals(events.event, '$pageview'))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('purchased')), equals(events.event, 'purchased'))GROUP BY actor_id) AS retention_eventsGROUP BY actor_idHAVING 1) AS actor_activity@@ -1232,19 +1355,23 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_event_action+# name: TestRetention.test_retention_aggregation_different_events_ignores_start_event_property_value[new_events_schema]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,- count(DISTINCT actor_activity.actor_id) AS count+ count(DISTINCT actor_activity.actor_id) AS count,+ sum(actor_activity.retention_value) AS aggregation_valueFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'sign up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'signed_up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$some_event'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'signed_up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'purchased'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data,+ arrayMap(x -> x.1, _return_event_data) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), 0.0), _start_event_data)), arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 8), item.1), 1), 'Int64'), item.2), arrayFilter(x -> or(greater(x.1, date_range[plus(start_interval_index, 1)]), and(equals(x.1, date_range[plus(start_interval_index, 1)]), greater(x.3, arrayMin(arrayMap(y -> y.3, arrayFilter(z -> equals(z.1, date_range[plus(start_interval_index, 1)]), _start_event_data)))))), _return_event_data))))).1 AS intervals_from_base,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), 0.0), _start_event_data)), arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 8), item.1), 1), 'Int64'), item.2), arrayFilter(x -> or(greater(x.1, date_range[plus(start_interval_index, 1)]), and(equals(x.1, date_range[plus(start_interval_index, 1)]), greater(x.3, arrayMin(arrayMap(y -> y.3, arrayFilter(z -> equals(z.1, date_range[plus(start_interval_index, 1)]), _start_event_data)))))), _return_event_data))))).2 AS retention_value+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1252,7 +1379,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$some_event', 'sign up')), or(equals(events.event, 'sign up'), equals(events.event, '$some_event')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('purchased', 'signed_up')), or(equals(events.event, 'signed_up'), equals(events.event, 'purchased')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1273,18 +1400,22 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_event_action.1+# name: TestRetention.test_retention_aggregation_sum'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,- count(DISTINCT actor_activity.actor_id) AS count+ count(DISTINCT actor_activity.actor_id) AS count,+ sum(actor_activity.retention_value) AS aggregation_valueFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'sign up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$some_event'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data,+ arrayMap(x -> x.1, _return_event_data) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_valueFROM eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,@@ -1293,7 +1424,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$some_event', 'sign up')), or(equals(events.event, 'sign up'), equals(events.event, '$some_event')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1314,26 +1445,30 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence+# name: TestRetention.test_retention_aggregation_sum.1'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,- count(DISTINCT actor_activity.actor_id) AS count- FROM- (SELECT events.person_id AS actor_id,- if(has(arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.matches_start, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS _start_event_timestamps, toStartOfInterval(minIf(events.timestamp, equals(events.matches_start, 1)), toIntervalDay(1))), _start_event_timestamps, []) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,- arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])- and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])- and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ count(DISTINCT actor_activity.actor_id) AS count,+ sum(actor_activity.retention_value) AS aggregation_value+ FROM+ (SELECT retention_events.actor_id AS actor_id,+ arrayFlatten(groupArray(retention_events.start_event_timestamps)) AS start_event_timestamps,+ arrayFlatten(groupArray(retention_events.return_event_timestamps)) AS return_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arrayFlatten(groupArray(retention_events._start_event_data)) AS _start_event_data,+ arrayFlatten(groupArray(retention_events._return_event_data)) AS _return_event_data,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_valueFROM- (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 1 AS is_start,- 1 AS matches_start,- 0 AS is_return+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS start_event_timestamps,+ [] AS return_event_timestamps,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,+ [] AS _return_event_dataFROM eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,@@ -1342,12 +1477,13 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)))- UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 0 AS is_start,- 0 AS matches_start,- 1 AS is_return+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), equals(events.event, '$pageview'))+ GROUP BY actor_id+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ [] AS start_event_timestamps,+ arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS return_event_timestamps,+ [] AS _start_event_data,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_dataFROM eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,@@ -1356,7 +1492,8 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), equals(events.event, '$pageview'))+ GROUP BY actor_id) AS retention_eventsGROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1377,27 +1514,31 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence.1+# name: TestRetention.test_retention_aggregation_sum[new_events_schema.1]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,- count(DISTINCT actor_activity.actor_id) AS count+ count(DISTINCT actor_activity.actor_id) AS count,+ sum(actor_activity.retention_value) AS aggregation_valueFROM- (SELECT events.person_id AS actor_id,- if(and(greaterOrEquals(minIf(events.timestamp, equals(events.matches_start, 1)), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(minIf(events.timestamp, equals(events.matches_start, 1)), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), [toTimeZone(toStartOfInterval(minIf(events.timestamp, equals(events.matches_start, 1)), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,- arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])- and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])- and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ (SELECT retention_events.actor_id AS actor_id,+ arrayFlatten(groupArray(retention_events.start_event_timestamps)) AS start_event_timestamps,+ arrayFlatten(groupArray(retention_events.return_event_timestamps)) AS return_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arrayFlatten(groupArray(retention_events._start_event_data)) AS _start_event_data,+ arrayFlatten(groupArray(retention_events._return_event_data)) AS _return_event_data,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_valueFROM- (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 1 AS is_start,- 1 AS matches_start,- 0 AS is_return- FROM events+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS start_event_timestamps,+ [] AS return_event_timestamps,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,+ [] AS _return_event_data+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1405,13 +1546,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)))- UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 0 AS is_start,- 0 AS matches_start,- 1 AS is_return- FROM events+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), equals(events.event, '$pageview'))+ GROUP BY actor_id+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ [] AS start_event_timestamps,+ arraySort(arrayDistinct(arrayMap(x -> x.1, groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))))) AS return_event_timestamps,+ [] AS _start_event_data,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1419,7 +1561,1048 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), equals(events.event, '$pageview'))+ GROUP BY actor_id) AS retention_events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_aggregation_sum[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count,+ sum(actor_activity.retention_value) AS aggregation_value+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data,+ arrayMap(x -> x.1, _return_event_data) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(equals(item.1, date_range[plus(start_interval_index, 1)]), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_value+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_event_action+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'sign up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$some_event'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$some_event', 'sign up')), or(equals(events.event, 'sign up'), equals(events.event, '$some_event')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_event_action.1+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'sign up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$some_event'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$some_event', 'sign up')), or(equals(events.event, 'sign up'), equals(events.event, '$some_event')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_event_action[new_events_schema.1]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'sign up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$some_event'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$some_event', 'sign up')), or(equals(events.event, 'sign up'), equals(events.event, '$some_event')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_event_action[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'sign up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$some_event'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$some_event', 'sign up')), or(equals(events.event, 'sign up'), equals(events.event, '$some_event')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(has(arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.matches_start, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS _start_event_timestamps, toStartOfInterval(minIf(events.timestamp, equals(events.matches_start, 1)), toIntervalDay(1))), _start_event_timestamps, []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ 1 AS matches_start,+ 0 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence.1+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(and(greaterOrEquals(minIf(events.timestamp, equals(events.matches_start, 1)), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(minIf(events.timestamp, equals(events.matches_start, 1)), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), [toTimeZone(toStartOfInterval(minIf(events.timestamp, equals(events.matches_start, 1)), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ 1 AS matches_start,+ 0 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence.2+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(has(arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.matches_start, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS _start_event_timestamps, toStartOfInterval(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toIntervalDay(1))), _start_event_timestamps, []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)) AS matches_start,+ 0 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), equals(events.event, 'target_event'))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence.3+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(and(ifNull(greaterOrEquals(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), 0), ifNull(less(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), 0)), [toTimeZone(toStartOfInterval(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)) AS matches_start,+ 0 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), equals(events.event, 'target_event'))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence[new_events_schema.1]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(and(greaterOrEquals(minIf(events.timestamp, equals(events.matches_start, 1)), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(minIf(events.timestamp, equals(events.matches_start, 1)), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), [toTimeZone(toStartOfInterval(minIf(events.timestamp, equals(events.matches_start, 1)), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ 1 AS matches_start,+ 0 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), and(equals(events.event, 'target_event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^prop), '{}'), toJSONString(events.properties.^prop), if(isNull(events.properties.prop), NULL, if(startsWith(dynamicType(events.properties.prop), 'DateTime'), replaceOne(toString(events.properties.prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.prop), 'Array'), startsWith(dynamicType(events.properties.prop), 'Map'), startsWith(dynamicType(events.properties.prop), 'Tuple')), toJSONString(events.properties.prop), toString(events.properties.prop))))), 'correct'), 0)))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence[new_events_schema.2]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(has(arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.matches_start, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS _start_event_timestamps, toStartOfInterval(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toIntervalDay(1))), _start_event_timestamps, []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ and(equals(events.event, 'target_event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^prop), '{}'), toJSONString(events.properties.^prop), if(isNull(events.properties.prop), NULL, if(startsWith(dynamicType(events.properties.prop), 'DateTime'), replaceOne(toString(events.properties.prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.prop), 'Array'), startsWith(dynamicType(events.properties.prop), 'Map'), startsWith(dynamicType(events.properties.prop), 'Tuple')), toJSONString(events.properties.prop), toString(events.properties.prop))))), 'correct'), 0)) AS matches_start,+ 0 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), equals(events.event, 'target_event'))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence[new_events_schema.3]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(and(ifNull(greaterOrEquals(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), 0), ifNull(less(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), 0)), [toTimeZone(toStartOfInterval(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ and(equals(events.event, 'target_event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^prop), '{}'), toJSONString(events.properties.^prop), if(isNull(events.properties.prop), NULL, if(startsWith(dynamicType(events.properties.prop), 'DateTime'), replaceOne(toString(events.properties.prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.prop), 'Array'), startsWith(dynamicType(events.properties.prop), 'Map'), startsWith(dynamicType(events.properties.prop), 'Tuple')), toJSONString(events.properties.prop), toString(events.properties.prop))))), 'correct'), 0)) AS matches_start,+ 0 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), equals(events.event, 'target_event'))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT events.person_id AS actor_id,+ if(has(arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.matches_start, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS _start_event_timestamps, toStartOfInterval(minIf(events.timestamp, equals(events.matches_start, 1)), toIntervalDay(1))), _start_event_timestamps, []) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])+ and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])+ and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 1 AS is_start,+ 1 AS matches_start,+ 0 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), and(equals(events.event, 'target_event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^prop), '{}'), toJSONString(events.properties.^prop), if(isNull(events.properties.prop), NULL, if(startsWith(dynamicType(events.properties.prop), 'DateTime'), replaceOne(toString(events.properties.prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.prop), 'Array'), startsWith(dynamicType(events.properties.prop), 'Map'), startsWith(dynamicType(events.properties.prop), 'Tuple')), toJSONString(events.properties.prop), toString(events.properties.prop))))), 'correct'), 0)))+ UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,+ toTimeZone(events.timestamp, 'UTC') AS timestamp,+ 0 AS is_start,+ 0 AS matches_start,+ 1 AS is_return+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_with_user_properties_via_action+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id,+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview', 'non_matching_event')), or(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_with_user_properties_via_action.1+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id,+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview', 'non_matching_event')), or(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_with_user_properties_via_action[new_events_schema.1]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id,+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview', 'non_matching_event')), or(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_retention_with_user_properties_via_action[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id,+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview', 'non_matching_event')), or(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_timezones+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_timezones.1+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestRetention.test_timezones.2+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1440,49 +2623,27 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence.2+# name: TestRetention.test_timezones.3'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM- (SELECT events.person_id AS actor_id,- if(has(arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.matches_start, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS _start_event_timestamps, toStartOfInterval(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toIntervalDay(1))), _start_event_timestamps, []) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,- arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])- and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])- and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM- (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 1 AS is_start,- and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)) AS matches_start,- 0 AS is_return- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), equals(events.event, 'target_event'))- UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 0 AS is_start,- 0 AS matches_start,- 1 AS is_return- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1503,49 +2664,27 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_first_time_vs_first_ever_occurrence.3+# name: TestRetention.test_timezones[new_events_schema.1]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM- (SELECT events.person_id AS actor_id,- if(and(ifNull(greaterOrEquals(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), 0), ifNull(less(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), 0)), [toTimeZone(toStartOfInterval(if(equals(minIf(events.timestamp, equals(events.is_start, 1)), minIf(events.timestamp, equals(events.matches_start, 1))), minIf(events.timestamp, equals(events.is_start, 1)), NULL), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 6)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(events.timestamp), and(equals(events.is_return, 1), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,- arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])- and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])- and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM- (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 1 AS is_start,- and(equals(events.event, 'target_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'prop'), ''), 'null'), '^"|"$', ''), 'correct'), 0)) AS matches_start,- 0 AS is_return- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('target_event')), equals(events.event, 'target_event'))- UNION ALL SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,- toTimeZone(events.timestamp, 'UTC') AS timestamp,- 0 AS is_start,- 0 AS matches_start,- 1 AS is_return- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('returning_event')), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(events.event, 'returning_event'))) AS events+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1566,19 +2705,19 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_with_user_properties_via_action+# name: TestRetention.test_timezones[new_events_schema.2]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1586,17 +2725,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id,- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview', 'non_matching_event')), or(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), equals(events.event, '$pageview')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1617,19 +2746,19 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_retention_with_user_properties_via_action.1+# name: TestRetention.test_timezones[new_events_schema.3]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1637,17 +2766,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id,- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview', 'non_matching_event')), or(or(and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, '[email protected]'), 0)), equals(events.event, 'non_matching_event')), equals(events.event, '$pageview')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1668,7 +2787,7 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_timezones+# name: TestRetention.test_timezones[new_events_schema]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,@@ -1680,7 +2799,7 @@arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1709,18 +2828,18 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_timezones.1+# name: TestRetention.test_week_interval'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0), toIntervalWeek(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_baseFROM eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,@@ -1729,7 +2848,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1750,18 +2869,18 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_timezones.2+# name: TestRetention.test_week_interval.1'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS return_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0), toIntervalWeek(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_baseFROM eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,@@ -1770,7 +2889,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1791,18 +2910,18 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_timezones.3+# name: TestRetention.test_week_interval.2'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(x)), range(0, 11)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'US/Pacific')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'US/Pacific'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'US/Pacific'), toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')))))) AS return_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 3), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3), toIntervalWeek(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 3), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,- arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 11), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_baseFROM eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,@@ -1811,7 +2930,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'US/Pacific')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1832,16 +2951,16 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_week_interval+# name: TestRetention.test_week_interval.3'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,count(DISTINCT actor_activity.actor_id) AS countFROM(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,- arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,- arrayMap(x -> plus(toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0), toIntervalWeek(x)), range(0, 7)) AS date_range,- arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 3), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3), toIntervalWeek(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 3), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_baseFROM events@@ -1852,7 +2971,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))GROUP BY actor_idHAVING 1) AS actor_activityGROUP BY start_event_matching_interval,@@ -1873,7 +2992,7 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_week_interval.1+# name: TestRetention.test_week_interval[new_events_schema.1]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,@@ -1885,7 +3004,7 @@arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1914,7 +3033,7 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_week_interval.2+# name: TestRetention.test_week_interval[new_events_schema.2]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,@@ -1926,7 +3045,7 @@arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 3), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1955,7 +3074,7 @@use_hive_partitioning=0'''# ----# name: TestRetention.test_week_interval.3+# name: TestRetention.test_week_interval[new_events_schema.3]'''SELECT actor_activity.start_interval_index AS start_event_matching_interval,actor_activity.intervals_from_base AS intervals_from_base,@@ -1967,7 +3086,7 @@arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 3), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-08 00:00:00', 'UTC')), 3)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -1996,3 +3115,44 @@use_hive_partitioning=0'''# ---+# name: TestRetention.test_week_interval[new_events_schema]+ '''+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,+ actor_activity.intervals_from_base AS intervals_from_base,+ count(DISTINCT actor_activity.actor_id) AS count+ FROM+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,+ arrayMap(x -> plus(toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0), toIntervalWeek(x)), range(0, 7)) AS date_range,+ arraySort(groupUniqArrayIf(toStartOfWeek(toTimeZone(events.timestamp, 'UTC'), 0), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(has(_start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,+ arrayJoin(arrayConcat(if(has(start_event_timestamps, date_range[plus(start_interval_index, 1)]), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 7), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfWeek(assumeNotNull(toDateTime('2020-06-07 00:00:00', 'UTC')), 0)), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))+ GROUP BY actor_id+ HAVING 1) AS actor_activity+ GROUP BY start_event_matching_interval,+ intervals_from_base+ ORDER BY start_event_matching_interval ASC,+ intervals_from_base ASC+ LIMIT 100000 SETTINGS readonly=2,+ max_execution_time=600,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=23622320128,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr b/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambrindex 3de3dc4044cb..92f8c54f64ab 100644--- a/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr+++ b/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr@@ -132,37 +132,37 @@(SELECT person.id AS id,replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___nameFROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE and(equals(person.team_id, 99999), in(person.id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT DISTINCT actor_id AS actor_id- FROM- (SELECT min(events__person.created_at) AS created_at, arraySort(groupUniqArray(toStartOfInterval(toTimeZone(events.timestamp, 'US/Pacific'), toIntervalDay(1)))) AS all_activity, arrayPopBack(arrayPushFront(all_activity, toStartOfInterval(created_at, toIntervalDay(1)))) AS previous_activity, arrayPopFront(arrayPushBack(all_activity, toStartOfInterval(toDateTime('1970-01-01 00:00:00', 'US/Pacific'), toIntervalDay(1)))) AS following_activity, arrayMap((previous, current, index) -> if(ifNull(equals(previous, current), isNull(previous)- and isNull(current)), 'new', if(and(ifNull(equals(minus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)), previous), isNull(minus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)))- and isNull(previous)), ifNull(notEquals(index, 1), 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status, arrayMap((current, next) -> if(ifNull(equals(plus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)), toTimeZone(next, 'US/Pacific')), isNull(plus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)))- and isNull(toTimeZone(next, 'US/Pacific'))), '', 'dormant'), all_activity, following_activity) AS dormant_status, arrayMap(x -> plus(toTimeZone(x, 'US/Pacific'), toIntervalDay(1)), arrayFilter((current, is_dormant) -> ifNull(equals(is_dormant, 'dormant'), 0), all_activity, dormant_status)) AS dormant_periods, arrayMap(x -> 'dormant', dormant_periods) AS dormant_label, arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat, arrayJoin(temp_concat) AS period_status_pairs, period_status_pairs.1 AS start_of_period, period_status_pairs.2 AS status, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version) AS created_at, person.id AS id- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), ifNull(notEquals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$process_person_profile'), ''), 'null'), '^"|"$', ''), 'false'), 1), greaterOrEquals(events.timestamp, minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-09 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1))), less(events.timestamp, plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1))), equals(events.event, '$pageview'))- GROUP BY actor_id)- WHERE and(ifNull(equals(start_of_period, toStartOfInterval(toDateTime('2020-01-12', 'US/Pacific'), toIntervalDay(1))), isNull(start_of_period)- and isNull(toStartOfInterval(toDateTime('2020-01-12', 'US/Pacific'), toIntervalDay(1)))), equals(status, 'returning'))) AS source)))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)+ WHERE and(equals(person.team_id, 99999), globalIn(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE and(equals(person.team_id, 99999), globalIn(person.id,+ (SELECT source.actor_id AS actor_id+ FROM+ (SELECT DISTINCT actor_id AS actor_id+ FROM+ (SELECT min(events__person.created_at) AS created_at, arraySort(groupUniqArray(toStartOfInterval(toTimeZone(events.timestamp, 'US/Pacific'), toIntervalDay(1)))) AS all_activity, arrayPopBack(arrayPushFront(all_activity, toStartOfInterval(created_at, toIntervalDay(1)))) AS previous_activity, arrayPopFront(arrayPushBack(all_activity, toStartOfInterval(toDateTime('1970-01-01 00:00:00', 'US/Pacific'), toIntervalDay(1)))) AS following_activity, arrayMap((previous, current, index) -> if(ifNull(equals(previous, current), isNull(previous)+ and isNull(current)), 'new', if(and(ifNull(equals(minus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)), previous), isNull(minus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)))+ and isNull(previous)), ifNull(notEquals(index, 1), 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status, arrayMap((current, next) -> if(ifNull(equals(plus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)), toTimeZone(next, 'US/Pacific')), isNull(plus(toTimeZone(current, 'US/Pacific'), toIntervalDay(1)))+ and isNull(toTimeZone(next, 'US/Pacific'))), '', 'dormant'), all_activity, following_activity) AS dormant_status, arrayMap(x -> plus(toTimeZone(x, 'US/Pacific'), toIntervalDay(1)), arrayFilter((current, is_dormant) -> ifNull(equals(is_dormant, 'dormant'), 0), all_activity, dormant_status)) AS dormant_periods, arrayMap(x -> 'dormant', dormant_periods) AS dormant_label, arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat, arrayJoin(temp_concat) AS period_status_pairs, period_status_pairs.1 AS start_of_period, period_status_pairs.2 AS status, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version) AS created_at, person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), ifNull(notEquals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$process_person_profile'), ''), 'null'), '^"|"$', ''), 'false'), 1), greaterOrEquals(events.timestamp, minus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-09 00:00:00', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1))), less(events.timestamp, plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific')), toIntervalDay(1)), toIntervalDay(1))), equals(events.event, '$pageview'))+ GROUP BY actor_id)+ WHERE and(ifNull(equals(start_of_period, toStartOfInterval(toDateTime('2020-01-12', 'US/Pacific'), toIntervalDay(1))), isNull(start_of_period)+ and isNull(toStartOfInterval(toDateTime('2020-01-12', 'US/Pacific'), toIntervalDay(1)))), equals(status, 'returning'))) AS source)))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.properties___name ASC SETTINGS optimize_aggregation_in_order=1,join_algorithm='auto')LIMIT 100 SETTINGS readonly=2,@@ -254,31 +254,31 @@(SELECT person.id AS id,replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___nameFROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE and(equals(person.team_id, 99999), in(person.id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT aggregation_target AS actor_id- FROM- (SELECT aggregation_target AS aggregation_target, count() AS num_intervals- FROM- (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target, toStartOfInterval(toTimeZone(e.timestamp, 'US/Pacific'), toIntervalDay(1)) AS start_of_interval- FROM events AS e- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-01-09 00:00:00', 'US/Pacific')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific'))), equals(e.event, '$pageview'))- GROUP BY aggregation_target, start_of_interval- HAVING greater(count(), 0))- GROUP BY aggregation_target)- WHERE equals(num_intervals, 2)) AS source)))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)+ WHERE and(equals(person.team_id, 99999), globalIn(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE and(equals(person.team_id, 99999), globalIn(person.id,+ (SELECT source.actor_id AS actor_id+ FROM+ (SELECT aggregation_target AS actor_id+ FROM+ (SELECT aggregation_target AS aggregation_target, count() AS num_intervals+ FROM+ (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target, toStartOfInterval(toTimeZone(e.timestamp, 'US/Pacific'), toIntervalDay(1)) AS start_of_interval+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2020-01-09 00:00:00', 'US/Pacific')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-19 23:59:59', 'US/Pacific'))), equals(e.event, '$pageview'))+ GROUP BY aggregation_target, start_of_interval+ HAVING greater(count(), 0))+ GROUP BY aggregation_target)+ WHERE equals(num_intervals, 2)) AS source)))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.properties___name ASC SETTINGS optimize_aggregation_in_order=1,join_algorithm='auto')LIMIT 100 SETTINGS readonly=2,@@ -373,27 +373,27 @@(SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___name,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, max(timestamp) AS last_seen- FROM- (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id, toTimeZone(e.timestamp, 'US/Pacific') AS timestamp, e.uuid AS uuid, e.distinct_id AS distinct_id- FROM events AS e- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___email, person.id AS id- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)- WHERE and(equals(e.team_id, 99999), ifNull(notEquals(e__person.properties___email, '[email protected]'), 1), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), less(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), equals(e.event, '$pageview')))- GROUP BY actor_id) AS source)))+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_id+ FROM+ (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, max(timestamp) AS last_seen+ FROM+ (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id, toTimeZone(e.timestamp, 'US/Pacific') AS timestamp, e.uuid AS uuid, e.distinct_id AS distinct_id+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___email, person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)+ WHERE and(equals(e.team_id, 99999), ifNull(notEquals(e__person.properties___email, '[email protected]'), 1), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), less(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), equals(e.event, '$pageview')))+ GROUP BY actor_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.properties___name ASC SETTINGS optimize_aggregation_in_order=1,@@ -453,35 +453,35 @@(SELECT person.id AS id,replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___nameFROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE and(equals(person.team_id, 99999), in(person.id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, max(timestamp) AS last_seen- FROM- (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id, toTimeZone(e.timestamp, 'US/Pacific') AS timestamp, e.uuid AS uuid, e.distinct_id AS distinct_id- FROM events AS e- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)- WHERE and(equals(e.team_id, 99999), ifNull(notEquals(e__person.properties___email, '[email protected]'), 1), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), less(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), equals(e.event, '$pageview')))- GROUP BY actor_id) AS source)))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)+ WHERE and(equals(person.team_id, 99999), globalIn(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE and(equals(person.team_id, 99999), globalIn(person.id,+ (SELECT source.actor_id AS actor_id+ FROM+ (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, max(timestamp) AS last_seen+ FROM+ (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id, toTimeZone(e.timestamp, 'US/Pacific') AS timestamp, e.uuid AS uuid, e.distinct_id AS distinct_id+ FROM events AS e+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)+ WHERE and(equals(e.team_id, 99999), ifNull(notEquals(e__person.properties___email, '[email protected]'), 1), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), less(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'US/Pacific')), equals(e.event, '$pageview')))+ GROUP BY actor_id) AS source)))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.properties___name ASC SETTINGS optimize_aggregation_in_order=1,join_algorithm='auto')LIMIT 100 SETTINGS readonly=2,diff --git a/posthog/hogql_queries/insights/test/test_insight_actors_query_runner.py b/posthog/hogql_queries/insights/test/test_insight_actors_query_runner.pyindex 87cb7700aeff..86dc9b9271ba 100644--- a/posthog/hogql_queries/insights/test/test_insight_actors_query_runner.py+++ b/posthog/hogql_queries/insights/test/test_insight_actors_query_runner.py@@ -275,7 +275,7 @@ class TestInsightActorsQueryRunner(ClickhouseTestMixin, APIBaseTest):)self.assertEqual([("p2",)], response.results)- assert "in(id," in queries[0]+ assert "globalIn(id," in queries[0]self.assertEqual(2, queries[0].count("toTimeZone(e.timestamp, 'US/Pacific') AS timestamp"))@snapshot_clickhouse_queries@@ -303,7 +303,7 @@ class TestInsightActorsQueryRunner(ClickhouseTestMixin, APIBaseTest):)self.assertEqual([("p2", ["p2"])], response.results)- assert "in(id," in queries[0]+ assert "globalIn(id," in queries[0]self.assertEqual(2, queries[0].count("toTimeZone(e.timestamp, 'US/Pacific') AS timestamp"))@snapshot_clickhouse_queries@@ -331,7 +331,7 @@ class TestInsightActorsQueryRunner(ClickhouseTestMixin, APIBaseTest):)self.assertEqual([("p2", ["p2"])], response.results)- assert "in(person.id" in queries[0]+ assert "globalIn(person.id" in queries[0]self.assertEqual(2, queries[0].count("toTimeZone(e.timestamp, 'US/Pacific') AS timestamp"))@snapshot_clickhouse_queriesdiff --git a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambrindex a29b8255f7a4..e2c2bc678473 100644--- a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr+++ b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr@@ -159,20 +159,20 @@(SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, groupUniqArray(100)(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS matching_events, max(timestamp) AS last_seen- FROM- (SELECT e.person_id AS actor_id, toTimeZone(e.timestamp, 'UTC') AS timestamp, e.uuid AS uuid, e.`$session_id` AS `$session_id`, e.`$window_id` AS `$window_id`, e.distinct_id AS distinct_id- FROM events AS e- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), greaterOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), less(timestamp, toDateTime64('2020-01-03 00:00:00.000000', 6, 'UTC')), ifNull(equals(ifNull(nullIf(leftUTF8(toString(e__group_0.properties___industry), 400), ''), '$$_posthog_breakdown_null_$$'), 'technology'), 0), equals(e.event, 'sign up')))- GROUP BY actor_id) AS source)))+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_id+ FROM+ (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, groupUniqArray(100)(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS matching_events, max(timestamp) AS last_seen+ FROM+ (SELECT e.person_id AS actor_id, toTimeZone(e.timestamp, 'UTC') AS timestamp, e.uuid AS uuid, e.`$session_id` AS `$session_id`, e.`$window_id` AS `$window_id`, e.distinct_id AS distinct_id+ FROM events AS e+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), greaterOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), less(timestamp, toDateTime64('2020-01-03 00:00:00.000000', 6, 'UTC')), ifNull(equals(ifNull(nullIf(leftUTF8(toString(e__group_0.properties___industry), 400), ''), '$$_posthog_breakdown_null_$$'), 'technology'), 0), equals(e.event, 'sign up')))+ GROUP BY actor_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY source.event_count DESC@@ -1107,25 +1107,25 @@(SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, groupUniqArray(100)(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS matching_events, max(timestamp) AS last_seen- FROM- (SELECT e.person_id AS actor_id, toTimeZone(e.timestamp, 'UTC') AS timestamp, e.uuid AS uuid, e.`$session_id` AS `$session_id`, e.`$window_id` AS `$window_id`, e.distinct_id AS distinct_id- FROM events AS e- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 2))- GROUP BY groups.group_type_index, groups.group_key) AS e__group_2 ON equals(e.`$group_2`, e__group_2.key)- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(ifNull(equals(e__group_0.properties___industry, 'finance'), 0), ifNull(equals(e__group_2.properties___name, 'six'), 0)), greaterOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), less(timestamp, toDateTime64('2020-01-03 00:00:00.000000', 6, 'UTC')), equals(e.event, 'sign up')))- GROUP BY actor_id) AS source)))+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_id+ FROM+ (SELECT actor_id AS actor_id, count() AS event_count, groupUniqArray(distinct_id) AS event_distinct_ids, groupUniqArray(100)(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS matching_events, max(timestamp) AS last_seen+ FROM+ (SELECT e.person_id AS actor_id, toTimeZone(e.timestamp, 'UTC') AS timestamp, e.uuid AS uuid, e.`$session_id` AS `$session_id`, e.`$window_id` AS `$window_id`, e.distinct_id AS distinct_id+ FROM events AS e+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 2))+ GROUP BY groups.group_type_index, groups.group_key) AS e__group_2 ON equals(e.`$group_2`, e__group_2.key)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 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, 99999), and(ifNull(equals(e__group_0.properties___industry, 'finance'), 0), ifNull(equals(e__group_2.properties___name, 'six'), 0)), greaterOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), less(timestamp, toDateTime64('2020-01-03 00:00:00.000000', 6, 'UTC')), equals(e.event, 'sign up')))+ GROUP BY actor_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY source.event_count DESCdiff --git a/posthog/hogql_queries/test/__snapshots__/test_events_query_runner.ambr b/posthog/hogql_queries/test/__snapshots__/test_events_query_runner.ambrindex c81e50e31e76..e9f38a8f853e 100644--- a/posthog/hogql_queries/test/__snapshots__/test_events_query_runner.ambr+++ b/posthog/hogql_queries/test/__snapshots__/test_events_query_runner.ambr@@ -3,12 +3,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2020-01-12 23:59:59.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-12 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC- LIMIT 101)), and(equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2020-01-12 23:59:59.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-12 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2020-01-12 23:59:59.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-12 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC+ LIMIT 101)), and(equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2020-01-12 23:59:59.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-12 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -104,12 +104,12 @@SELECT events.event AS event,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -158,12 +158,12 @@SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'idx'), ''), 'null'), '^"|"$', '') AS idx,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -185,12 +185,12 @@SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'idx'), ''), 'null'), '^"|"$', '') AS idx,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -212,12 +212,12 @@SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'idx'), ''), 'null'), '^"|"$', '') AS idx,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -320,12 +320,12 @@SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'idx'), ''), 'null'), '^"|"$', '') AS idx,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -347,12 +347,12 @@SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'idx'), ''), 'null'), '^"|"$', '') AS idx,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-11 12:00:04.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -374,12 +374,12 @@SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'idx'), ''), 'null'), '^"|"$', '') AS idx,toTimeZone(events.timestamp, 'UTC') AS timestampFROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-11 12:00:02.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -481,12 +481,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC- LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESC+ LIMIT 3)), and(less(events.timestamp, toDateTime64('2020-01-12 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.uuid DESCLIMIT 3OFFSET 0 SETTINGS readonly=2,@@ -535,12 +535,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), notILike(toString(events.elements_chain), '%div%'), equals(events.event, '$autocapture'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-20 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC- LIMIT 101)), and(notILike(toString(events.elements_chain), '%div%'), equals(events.event, '$autocapture'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-20 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), notILike(toString(events.elements_chain), '%div%'), equals(events.event, '$autocapture'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-20 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC+ LIMIT 101)), and(notILike(toString(events.elements_chain), '%div%'), equals(events.event, '$autocapture'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-20 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -589,12 +589,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'some_prop'), ''), 'null'), '^"|"$', ''), 'a'), 0), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC- LIMIT 101)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'some_prop'), ''), 'null'), '^"|"$', ''), 'a'), 0), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'some_prop'), ''), 'null'), '^"|"$', ''), 'a'), 0), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASC+ LIMIT 101)), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'some_prop'), ''), 'null'), '^"|"$', ''), 'a'), 0), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') ASC, events.uuid ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -643,12 +643,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))- ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.event ASC, events.uuid DESC- LIMIT 101)), and(equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))+ ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.event ASC, events.uuid DESC+ LIMIT 101)), and(equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))ORDER BY toTimeZone(events.timestamp, 'UTC') DESC, events.event ASC,events.uuid DESCLIMIT 101@@ -698,12 +698,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))- ORDER BY events.event ASC- LIMIT 101)), and(less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))+ ORDER BY events.event ASC+ LIMIT 101)), and(less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))ORDER BY events.event ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,@@ -752,12 +752,12 @@'''SELECT tuple(events.uuid, events.event, events.properties, toTimeZone(events.timestamp, 'UTC'), events.team_id, events.distinct_id, events.elements_chain, toTimeZone(events.created_at, 'UTC'), events.person_mode) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`FROM events- WHERE and(equals(events.team_id, 99999), in(events.uuid,- (SELECT events.uuid AS uuid- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))- ORDER BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'priority'), ''), 'null'), '^"|"$', '') ASC- LIMIT 101)), and(equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))+ WHERE and(equals(events.team_id, 99999), globalIn(events.uuid,+ (SELECT events.uuid AS uuid+ FROM events+ WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')))+ ORDER BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'priority'), ''), 'null'), '^"|"$', '') ASC+ LIMIT 101)), and(equals(events.event, '$pageview'), less(events.timestamp, toDateTime64('2021-01-21 00:00:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC'))))ORDER BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'priority'), ''), 'null'), '^"|"$', '') ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,diff --git a/posthog/models/test/__snapshots__/test_async_deletion_model.ambr b/posthog/models/test/__snapshots__/test_async_deletion_model.ambrindex b348652c3814..c7113d7e6723 100644--- a/posthog/models/test/__snapshots__/test_async_deletion_model.ambr+++ b/posthog/models/test/__snapshots__/test_async_deletion_model.ambr@@ -31,6 +31,16 @@AND $group_0 = 'foo')'''# ---+# name: TestAsyncDeletion.test_mark_deletions_done_groups[new_events_schema]+ '''++ SELECT DISTINCT team_id,+ $group_0+ FROM events_json+ WHERE (team_id = 99999+ AND $group_0 = 'foo')+ '''+# ---# name: TestAsyncDeletion.test_mark_deletions_done_groups_when_not_done'''@@ -51,6 +61,16 @@AND $group_0 = 'foo')'''# ---+# name: TestAsyncDeletion.test_mark_deletions_done_groups_when_not_done[new_events_schema]+ '''++ SELECT DISTINCT team_id,+ $group_0+ FROM events_json+ WHERE (team_id = 99999+ AND $group_0 = 'foo')+ '''+# ---# name: TestAsyncDeletion.test_mark_deletions_done_person'''@@ -73,6 +93,17 @@AND _timestamp <= '2024-01-01 00:00:00''''# ---+# name: TestAsyncDeletion.test_mark_deletions_done_person[new_events_schema]+ '''++ SELECT DISTINCT team_id,+ person_id+ FROM events_json+ WHERE (team_id = 99999+ AND person_id = '00000000-0000-0000-0000-000000000000')+ AND _timestamp <= '2024-01-01 00:00:00'+ '''+# ---# name: TestAsyncDeletion.test_mark_deletions_done_person_when_not_done'''@@ -95,6 +126,17 @@AND _timestamp <= '2024-01-01 00:00:00''''# ---+# name: TestAsyncDeletion.test_mark_deletions_done_person_when_not_done[new_events_schema]+ '''++ SELECT DISTINCT team_id,+ person_id+ FROM events_json+ WHERE (team_id = 99999+ AND person_id = '00000000-0000-0000-0000-000000000000')+ AND _timestamp <= '2024-01-01 00:00:00'+ '''+# ---# name: TestAsyncDeletion.test_mark_deletions_done_team_when_not_done'''@@ -111,6 +153,14 @@WHERE team_id = 99999'''# ---+# name: TestAsyncDeletion.test_mark_deletions_done_team_when_not_done[new_events_schema]+ '''++ SELECT DISTINCT team_id+ FROM events_json+ WHERE team_id = 99999+ '''+# ---# name: TestAsyncDeletion.test_mark_team_deletions_done'''@@ -127,3 +177,11 @@WHERE team_id = 99999'''# ---+# name: TestAsyncDeletion.test_mark_team_deletions_done[new_events_schema]+ '''++ SELECT DISTINCT team_id+ FROM events_json+ WHERE team_id = 99999+ '''+# ---diff --git a/posthog/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.ambr b/posthog/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.ambrindex 1a0eae289a2d..be2a581ca0d8 100644--- a/posthog/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.ambr+++ b/posthog/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.ambr@@ -66,6 +66,48 @@use_hive_partitioning=0'''# ---+# name: TestTimezonePreAggregatedIntegration.test_india_half_hour_timezone_edge_case[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Kolkata'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Kolkata'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Kolkata'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Kolkata')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit'''SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,@@ -267,32 +309,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_00_- '''- SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,- divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`- FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07:59:59.999999', 6, 'UTC')))- GROUP BY `context.columns.breakdown_value`- ORDER BY `context.columns.visitors` DESC- LIMIT 101- OFFSET 0 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit[new_events_schema.1]'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -301,10 +318,10 @@FROM(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,count() AS filtered_pageview_count,- nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ events.properties.`$browser` AS breakdown_value,if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -334,16 +351,33 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_+# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit[new_events_schema.2]'''- SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`- FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04:59:59.999999', 6, 'UTC')))+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Tokyo'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Tokyo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)GROUP BY `context.columns.breakdown_value`- ORDER BY `context.columns.visitors` DESC+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASCLIMIT 101OFFSET 0 SETTINGS readonly=2,max_execution_time=60,@@ -359,7 +393,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit[new_events_schema]'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -368,10 +402,10 @@FROM(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,count() AS filtered_pageview_count,- nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ events.properties.`$browser` AS breakdown_value,if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -379,7 +413,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/New_York'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/New_York'))), lessOrEquals(toTimeZone(events.timestamp, 'America/New_York'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/New_York')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -401,14 +435,14 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_00_'''SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 03:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 02:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 03:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 02:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 03:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 02:59:59.999999', 6, 'UTC')))+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07:59:59.999999', 6, 'UTC')))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESCLIMIT 101@@ -426,7 +460,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_00_.1'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -446,7 +480,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/Sao_Paulo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/Sao_Paulo'))), lessOrEquals(toTimeZone(events.timestamp, 'America/Sao_Paulo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/Sao_Paulo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/Los_Angeles'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/Los_Angeles'))), lessOrEquals(toTimeZone(events.timestamp, 'America/Los_Angeles'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/Los_Angeles')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -468,32 +502,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_- '''- SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,- divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`- FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23:59:59.999999', 6, 'UTC')))- GROUP BY `context.columns.breakdown_value`- ORDER BY `context.columns.visitors` DESC- LIMIT 101- OFFSET 0 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_00_[new_events_schema]'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -502,10 +511,10 @@FROM(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,count() AS filtered_pageview_count,- nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ events.properties.`$browser` AS breakdown_value,if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -513,7 +522,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/Los_Angeles'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/Los_Angeles'))), lessOrEquals(toTimeZone(events.timestamp, 'America/Los_Angeles'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/Los_Angeles')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -535,14 +544,14 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_04_Berlin_UTC_01_00_+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_'''SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 23:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 22:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 23:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 22:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 23:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 22:59:59.999999', 6, 'UTC')))+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04:59:59.999999', 6, 'UTC')))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESCLIMIT 101@@ -560,7 +569,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_04_Berlin_UTC_01_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_.1'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -580,7 +589,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Europe/Berlin'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Europe/Berlin'))), lessOrEquals(toTimeZone(events.timestamp, 'Europe/Berlin'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Europe/Berlin')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/New_York'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/New_York'))), lessOrEquals(toTimeZone(events.timestamp, 'America/New_York'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/New_York')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -602,32 +611,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_05_Cairo_UTC_02_00_- '''- SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 22:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 21:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 22:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 21:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,- divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`- FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 22:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 21:59:59.999999', 6, 'UTC')))- GROUP BY `context.columns.breakdown_value`- ORDER BY `context.columns.visitors` DESC- LIMIT 101- OFFSET 0 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_05_Cairo_UTC_02_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_[new_events_schema]'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -636,10 +620,10 @@FROM(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,count() AS filtered_pageview_count,- nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ events.properties.`$browser` AS breakdown_value,if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -647,7 +631,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Africa/Cairo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Africa/Cairo'))), lessOrEquals(toTimeZone(events.timestamp, 'Africa/Cairo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Africa/Cairo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/New_York'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/New_York'))), lessOrEquals(toTimeZone(events.timestamp, 'America/New_York'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/New_York')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -669,14 +653,14 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_06_Moscow_UTC_03_00_+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_'''SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 21:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 20:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 21:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 20:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 03:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 02:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 03:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 02:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 21:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 20:59:59.999999', 6, 'UTC')))+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 03:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 02:59:59.999999', 6, 'UTC')))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESCLIMIT 101@@ -694,7 +678,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_06_Moscow_UTC_03_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_.1'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -714,7 +698,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Europe/Moscow'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Europe/Moscow'))), lessOrEquals(toTimeZone(events.timestamp, 'Europe/Moscow'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Europe/Moscow')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/Sao_Paulo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/Sao_Paulo'))), lessOrEquals(toTimeZone(events.timestamp, 'America/Sao_Paulo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/Sao_Paulo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -736,32 +720,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_07_Pakistan_UTC_05_00_- '''- SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 19:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 18:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 19:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 18:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,- divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`- FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 19:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 18:59:59.999999', 6, 'UTC')))- GROUP BY `context.columns.breakdown_value`- ORDER BY `context.columns.visitors` DESC- LIMIT 101- OFFSET 0 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_07_Pakistan_UTC_05_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_[new_events_schema]'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -770,10 +729,10 @@FROM(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,count() AS filtered_pageview_count,- nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ events.properties.`$browser` AS breakdown_value,if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp- FROM events+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,person_distinct_id_overrides.distinct_id AS distinct_id@@ -781,7 +740,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Karachi'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Karachi'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Karachi'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Karachi')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'America/Sao_Paulo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'America/Sao_Paulo'))), lessOrEquals(toTimeZone(events.timestamp, 'America/Sao_Paulo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'America/Sao_Paulo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -803,14 +762,14 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_08_Tokyo_UTC_09_00_+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_'''SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 15:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 14:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 15:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 14:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 15:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 14:59:59.999999', 6, 'UTC')))+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23:59:59.999999', 6, 'UTC')))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESCLIMIT 101@@ -828,7 +787,7 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_08_Tokyo_UTC_09_00_.1+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_.1'''SELECT breakdown_value AS `context.columns.breakdown_value`,tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,@@ -848,7 +807,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Tokyo'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Tokyo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))GROUP BY session_id,breakdown_value)GROUP BY `context.columns.breakdown_value`@@ -870,23 +829,610 @@use_hive_partitioning=0'''# ----# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_09_Sydney_UTC_11_00_+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_[new_events_schema]'''- SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,- tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 13:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 12:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,- tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 13:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 12:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`- FROM web_pre_aggregated_stats- WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 13:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 12:59:59.999999', 6, 'UTC')))- GROUP BY `context.columns.breakdown_value`- ORDER BY `context.columns.visitors` DESC- LIMIT 101- OFFSET 0 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_04_Berlin_UTC_01_00_+ '''+ SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 23:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 22:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 23:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 22:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM web_pre_aggregated_stats+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 23:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 22:59:59.999999', 6, 'UTC')))+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_04_Berlin_UTC_01_00_.1+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Europe/Berlin'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Europe/Berlin'))), lessOrEquals(toTimeZone(events.timestamp, 'Europe/Berlin'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Europe/Berlin')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_04_Berlin_UTC_01_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Europe/Berlin'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Europe/Berlin'))), lessOrEquals(toTimeZone(events.timestamp, 'Europe/Berlin'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Europe/Berlin')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_05_Cairo_UTC_02_00_+ '''+ SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 22:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 21:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 22:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 21:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM web_pre_aggregated_stats+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 22:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 21:59:59.999999', 6, 'UTC')))+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_05_Cairo_UTC_02_00_.1+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Africa/Cairo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Africa/Cairo'))), lessOrEquals(toTimeZone(events.timestamp, 'Africa/Cairo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Africa/Cairo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_05_Cairo_UTC_02_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Africa/Cairo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Africa/Cairo'))), lessOrEquals(toTimeZone(events.timestamp, 'Africa/Cairo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Africa/Cairo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_06_Moscow_UTC_03_00_+ '''+ SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 21:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 20:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 21:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 20:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM web_pre_aggregated_stats+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 21:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 20:59:59.999999', 6, 'UTC')))+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_06_Moscow_UTC_03_00_.1+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Europe/Moscow'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Europe/Moscow'))), lessOrEquals(toTimeZone(events.timestamp, 'Europe/Moscow'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Europe/Moscow')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_06_Moscow_UTC_03_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Europe/Moscow'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Europe/Moscow'))), lessOrEquals(toTimeZone(events.timestamp, 'Europe/Moscow'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Europe/Moscow')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_07_Pakistan_UTC_05_00_+ '''+ SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 19:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 18:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 19:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 18:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM web_pre_aggregated_stats+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 19:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 18:59:59.999999', 6, 'UTC')))+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_07_Pakistan_UTC_05_00_.1+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Karachi'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Karachi'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Karachi'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Karachi')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_07_Pakistan_UTC_05_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Karachi'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Karachi'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Karachi'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Karachi')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_08_Tokyo_UTC_09_00_+ '''+ SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 15:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 14:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 15:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 14:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM web_pre_aggregated_stats+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 15:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 14:59:59.999999', 6, 'UTC')))+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_08_Tokyo_UTC_09_00_.1+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Tokyo'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Tokyo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_08_Tokyo_UTC_09_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Asia/Tokyo'))), lessOrEquals(toTimeZone(events.timestamp, 'Asia/Tokyo'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Asia/Tokyo')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_09_Sydney_UTC_11_00_+ '''+ SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,+ tuple(uniqMergeIf(web_pre_aggregated_stats.persons_uniq_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 13:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 12:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.visitors`,+ tuple(sumMergeIf(web_pre_aggregated_stats.pageviews_count_state, and(greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 13:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 12:59:59.999999', 6, 'UTC')))), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM web_pre_aggregated_stats+ WHERE and(equals(web_pre_aggregated_stats.team_id, 99999), greaterOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-14 13:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 12:59:59.999999', 6, 'UTC')))+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,transform_null_in=1,optimize_min_equality_disjunction_chain_length=4294967295,optimize_rewrite_aggregate_function_with_if=0,@@ -937,6 +1483,48 @@use_hive_partitioning=0'''# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_09_Sydney_UTC_11_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Australia/Sydney'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Australia/Sydney'))), lessOrEquals(toTimeZone(events.timestamp, 'Australia/Sydney'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Australia/Sydney')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_10_Auckland_UTC_12_00_'''SELECT nullIf(nullIf(web_pre_aggregated_stats.browser, ''), 'null') AS `context.columns.breakdown_value`,@@ -1004,3 +1592,45 @@use_hive_partitioning=0'''# ---+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_10_Auckland_UTC_12_00_[new_events_schema]+ '''+ SELECT breakdown_value AS `context.columns.breakdown_value`,+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`+ FROM+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,+ count() AS filtered_pageview_count,+ events.properties.`$browser` AS breakdown_value,+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,+ person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'Pacific/Auckland'), assumeNotNull(toDateTime('2024-01-15 00:00:00', 'Pacific/Auckland'))), lessOrEquals(toTimeZone(events.timestamp, 'Pacific/Auckland'), assumeNotNull(toDateTime('2024-01-16 23:59:59', 'Pacific/Auckland')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))+ GROUP BY session_id,+ breakdown_value)+ GROUP BY `context.columns.breakdown_value`+ ORDER BY `context.columns.visitors` DESC,+ `context.columns.views` DESC,+ `context.columns.breakdown_value` ASC+ LIMIT 101+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_by_top_level_event_property.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_by_top_level_event_property.ambrindex 12ae4e8167e9..23162d1f9e98 100644--- a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_by_top_level_event_property.ambr+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_by_top_level_event_property.ambr@@ -47,6 +47,54 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_does_not_contain_event_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^something), '{}'), toJSONString(events.properties.^something), if(isNull(events.properties.something), NULL, if(startsWith(dynamicType(events.properties.something), 'DateTime'), replaceOne(toString(events.properties.something), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.something), 'Array'), startsWith(dynamicType(events.properties.something), 'Map'), startsWith(dynamicType(events.properties.something), 'Tuple')), toJSONString(events.properties.something), toString(events.properties.something)))))), '%paul.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_does_not_match_regex_event_properties'''SELECT s.session_id AS session_id,@@ -95,6 +143,54 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_does_not_match_regex_event_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(events.properties.`$host`), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_0_session_1_matches_target_flag_is_True'''SELECT s.session_id AS session_id,@@ -145,6 +241,56 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_0_session_1_matches_target_flag_is_True[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(in(events.event, ['$pageview', 'bar', 'baz', 'foo']), ifNull(equals(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`))))), 'true'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_1_session_2_matches_target_flag_is_False'''SELECT s.session_id AS session_id,@@ -195,6 +341,56 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_1_session_2_matches_target_flag_is_False[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(in(events.event, ['$pageview', 'bar', 'baz', 'foo']), ifNull(equals(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`))))), 'false'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_2_sessions_1_and_2_match_target_flag_is_set'''SELECT s.session_id AS session_id,@@ -245,7 +441,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_2_sessions_1_and_2_match_target_flag_is_set[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -269,12 +465,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', '')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(in(events.event, ['$pageview', 'bar', 'baz', 'foo']), isNotNull(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`))))))), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -293,7 +491,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_two_is_not_event_properties+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -320,7 +518,7 @@WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-one'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-two'), ''), 'null'), '^"|"$', ''), 'val'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', '')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')LIMIT 1000000)))GROUP BY s.session_id@@ -341,7 +539,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_contain_event_properties+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -366,10 +564,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'something'), ''), 'null'), '^"|"$', '')), '%paul.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`)))))), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))@@ -389,7 +587,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_match_regex_event_properties+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_two_is_not_event_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -416,7 +614,7 @@WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-one'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-two'), ''), 'null'), '^"|"$', ''), 'val'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')LIMIT 1000000)))GROUP BY s.session_id@@ -437,7 +635,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_0_session_1_matches_target_flag_is_True+# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_two_is_not_event_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -461,14 +659,12 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', ''), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(if(notEquals(toJSONString(events.properties.^`probe-one`), '{}'), toJSONString(events.properties.^`probe-one`), if(isNull(events.properties.`probe-one`), NULL, if(startsWith(dynamicType(events.properties.`probe-one`), 'DateTime'), replaceOne(toString(events.properties.`probe-one`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`probe-one`), 'Array'), startsWith(dynamicType(events.properties.`probe-one`), 'Map'), startsWith(dynamicType(events.properties.`probe-one`), 'Tuple')), toJSONString(events.properties.`probe-one`), toString(events.properties.`probe-one`))))), 'val'), 0), ifNull(equals(if(notEquals(toJSONString(events.properties.^`probe-two`), '{}'), toJSONString(events.properties.^`probe-two`), if(isNull(events.properties.`probe-two`), NULL, if(startsWith(dynamicType(events.properties.`probe-two`), 'DateTime'), replaceOne(toString(events.properties.`probe-two`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`probe-two`), 'Array'), startsWith(dynamicType(events.properties.`probe-two`), 'Map'), startsWith(dynamicType(events.properties.`probe-two`), 'Tuple')), toJSONString(events.properties.`probe-two`), toString(events.properties.`probe-two`))))), 'val'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -487,7 +683,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_1_session_2_matches_target_flag_is_False+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_contain_event_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -511,14 +707,12 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'something'), ''), 'null'), '^"|"$', '')), '%paul.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -537,7 +731,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_2_sessions_1_and_2_match_target_flag_is_set+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_contain_event_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -561,14 +755,12 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', '')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^something), '{}'), toJSONString(events.properties.^something), if(isNull(events.properties.something), NULL, if(startsWith(dynamicType(events.properties.something), 'DateTime'), replaceOne(toString(events.properties.something), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.something), 'Array'), startsWith(dynamicType(events.properties.something), 'Map'), startsWith(dynamicType(events.properties.something), 'Tuple')), toJSONString(events.properties.something), toString(events.properties.something)))))), '%paul.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -587,7 +779,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_match_regex_event_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -614,7 +806,7 @@WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', '')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')LIMIT 1000000)))GROUP BY s.session_id@@ -635,7 +827,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_two_is_not_event_properties+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_match_regex_event_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -660,10 +852,502 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-one'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-two'), ''), 'null'), '^"|"$', ''), 'val'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(events.properties.`$host`), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_0_session_1_matches_target_flag_is_True+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', ''), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_0_session_1_matches_target_flag_is_True[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`))))), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_1_session_2_matches_target_flag_is_False+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_1_session_2_matches_target_flag_is_False[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_2_sessions_1_and_2_match_target_flag_is_set+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', '')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_2_sessions_1_and_2_match_target_flag_is_set[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`)))))), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$feature/target-flag'), ''), 'null'), '^"|"$', '')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^`$feature/target-flag`), '{}'), toJSONString(events.properties.^`$feature/target-flag`), if(isNull(events.properties.`$feature/target-flag`), NULL, if(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'DateTime'), replaceOne(toString(events.properties.`$feature/target-flag`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Array'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Map'), startsWith(dynamicType(events.properties.`$feature/target-flag`), 'Tuple')), toJSONString(events.properties.`$feature/target-flag`), toString(events.properties.`$feature/target-flag`)))))), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_two_is_not_event_properties+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-one'), ''), 'null'), '^"|"$', ''), 'val'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'probe-two'), ''), 'null'), '^"|"$', ''), 'val'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_two_is_not_event_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(if(notEquals(toJSONString(events.properties.^`probe-one`), '{}'), toJSONString(events.properties.^`probe-one`), if(isNull(events.properties.`probe-one`), NULL, if(startsWith(dynamicType(events.properties.`probe-one`), 'DateTime'), replaceOne(toString(events.properties.`probe-one`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`probe-one`), 'Array'), startsWith(dynamicType(events.properties.`probe-one`), 'Map'), startsWith(dynamicType(events.properties.`probe-one`), 'Tuple')), toJSONString(events.properties.`probe-one`), toString(events.properties.`probe-one`))))), 'val'), 0), ifNull(equals(if(notEquals(toJSONString(events.properties.^`probe-two`), '{}'), toJSONString(events.properties.^`probe-two`), if(isNull(events.properties.`probe-two`), NULL, if(startsWith(dynamicType(events.properties.`probe-two`), 'DateTime'), replaceOne(toString(events.properties.`probe-two`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`probe-two`), 'Array'), startsWith(dynamicType(events.properties.`probe-two`), 'Map'), startsWith(dynamicType(events.properties.`probe-two`), 'Tuple')), toJSONString(events.properties.`probe-two`), toString(events.properties.`probe-two`))))), 'val'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_from_query.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_from_query.ambrindex f9d836fef2fe..0d14fb69b465 100644--- a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_from_query.ambr+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_from_query.ambr@@ -38,6 +38,45 @@LIMIT 50000'''# ---+# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_0_test_poe_v1_still_falls_back_to_person_subquery[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, %(hogql_val_0)s)) AS start_time,+ max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,+ dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc(%(hogql_val_3)s, start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff(%(hogql_val_4)s, toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, %(hogql_val_5)s)), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff(%(hogql_val_6)s, start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, %(hogql_val_7)s)), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^rgInternal), '{}'), toJSONString(events.person_properties.^rgInternal), if(isNull(events.person_properties.rgInternal), NULL, if(startsWith(dynamicType(events.person_properties.rgInternal), 'DateTime'), replaceOne(toString(events.person_properties.rgInternal), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.rgInternal), 'Array'), startsWith(dynamicType(events.person_properties.rgInternal), 'Map'), startsWith(dynamicType(events.person_properties.rgInternal), 'Tuple')), toJSONString(events.person_properties.rgInternal), toString(events.person_properties.rgInternal))))), %(hogql_val_8)s), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, %(hogql_val_9)s)) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 50000+ '''+# ---# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_1_test_poe_being_unavailable_we_fall_back_to_person_id_overrides'''SELECT s.session_id AS session_id,@@ -89,6 +128,57 @@LIMIT 50000'''# ---+# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_1_test_poe_being_unavailable_we_fall_back_to_person_id_overrides[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, %(hogql_val_0)s)) AS start_time,+ max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,+ dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc(%(hogql_val_3)s, start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff(%(hogql_val_4)s, toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, %(hogql_val_5)s)), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff(%(hogql_val_6)s, start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_7)s), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___rgInternal, person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_8)s), person.version), plus(now64(6, %(hogql_val_9)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, %(hogql_val_10)s)), ifNull(equals(events__person.properties___rgInternal, %(hogql_val_11)s), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, %(hogql_val_12)s)) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 50000+ '''+# ---# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_2_test_poe_being_unavailable_we_fall_back_to_person_subquery_but_still_use_mat_props'''SELECT s.session_id AS session_id,@@ -140,6 +230,57 @@LIMIT 50000'''# ---+# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_2_test_poe_being_unavailable_we_fall_back_to_person_subquery_but_still_use_mat_props[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, %(hogql_val_0)s)) AS start_time,+ max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,+ dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc(%(hogql_val_3)s, start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff(%(hogql_val_4)s, toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, %(hogql_val_5)s)), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff(%(hogql_val_6)s, start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_7)s), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___rgInternal, person.id AS id+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_8)s), person.version), plus(now64(6, %(hogql_val_9)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, %(hogql_val_10)s)), ifNull(equals(events__person.properties___rgInternal, %(hogql_val_11)s), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, %(hogql_val_12)s)) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 50000+ '''+# ---# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_3_test_allow_denormalised_props_fix_does_not_stop_all_poe_processing'''SELECT s.session_id AS session_id,@@ -179,6 +320,45 @@LIMIT 50000'''# ---+# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_3_test_allow_denormalised_props_fix_does_not_stop_all_poe_processing[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, %(hogql_val_0)s)) AS start_time,+ max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,+ dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc(%(hogql_val_3)s, start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff(%(hogql_val_4)s, toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, %(hogql_val_5)s)), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff(%(hogql_val_6)s, start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, %(hogql_val_7)s)), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^rgInternal), '{}'), toJSONString(events.person_properties.^rgInternal), if(isNull(events.person_properties.rgInternal), NULL, if(startsWith(dynamicType(events.person_properties.rgInternal), 'DateTime'), replaceOne(toString(events.person_properties.rgInternal), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.rgInternal), 'Array'), startsWith(dynamicType(events.person_properties.rgInternal), 'Map'), startsWith(dynamicType(events.person_properties.rgInternal), 'Tuple')), toJSONString(events.person_properties.rgInternal), toString(events.person_properties.rgInternal))))), %(hogql_val_8)s), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, %(hogql_val_9)s)) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 50000+ '''+# ---# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_4_test_poe_v2_available_person_properties_are_used_in_replay_listing'''SELECT s.session_id AS session_id,@@ -218,6 +398,45 @@LIMIT 50000'''# ---+# name: TestClickhouseSessionRecordingsListFromQuery.test_effect_of_poe_settings_on_query_generated_4_test_poe_v2_available_person_properties_are_used_in_replay_listing[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, %(hogql_val_0)s)) AS start_time,+ max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,+ dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc(%(hogql_val_3)s, start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff(%(hogql_val_4)s, toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, %(hogql_val_5)s)), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff(%(hogql_val_6)s, start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, %(hogql_val_7)s)), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^rgInternal), '{}'), toJSONString(events.person_properties.^rgInternal), if(isNull(events.person_properties.rgInternal), NULL, if(startsWith(dynamicType(events.person_properties.rgInternal), 'DateTime'), replaceOne(toString(events.person_properties.rgInternal), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.rgInternal), 'Array'), startsWith(dynamicType(events.person_properties.rgInternal), 'Map'), startsWith(dynamicType(events.person_properties.rgInternal), 'Tuple')), toJSONString(events.person_properties.rgInternal), toString(events.person_properties.rgInternal))))), %(hogql_val_8)s), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, %(hogql_val_9)s)) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 50000+ '''+# ---# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_00_poe_v2_and_materialized_columns_allowed_with_materialization'''SELECT s.session_id AS session_id,@@ -311,7 +530,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_01_poe_v2_and_materialized_columns_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_00_poe_v2_and_materialized_columns_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -335,7 +554,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -354,7 +580,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_01_poe_v2_and_materialized_columns_allowed_without_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_01_poe_v2_and_materialized_columns_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -378,14 +604,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -404,7 +623,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_02_poe_v2_and_materialized_columns_off_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_01_poe_v2_and_materialized_columns_allowed_without_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -428,7 +647,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -447,7 +673,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_02_poe_v2_and_materialized_columns_off_with_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_01_poe_v2_and_materialized_columns_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -472,10 +698,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.mat_pp_email, 'bla'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -497,7 +723,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_03_poe_v2_and_materialized_columns_off_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_02_poe_v2_and_materialized_columns_off_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -540,7 +766,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_03_poe_v2_and_materialized_columns_off_without_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_02_poe_v2_and_materialized_columns_off_with_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -565,10 +791,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.mat_pp_email, 'bla'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -590,7 +816,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_04_poe_off_and_materialized_columns_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_02_poe_v2_and_materialized_columns_off_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -614,7 +840,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -633,7 +866,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_04_poe_off_and_materialized_columns_allowed_with_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_03_poe_v2_and_materialized_columns_off_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -657,29 +890,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -698,7 +909,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_05_poe_off_and_materialized_columns_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_03_poe_v2_and_materialized_columns_off_without_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -722,7 +933,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -741,7 +959,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_05_poe_off_and_materialized_columns_allowed_without_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_03_poe_v2_and_materialized_columns_off_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -765,29 +983,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -806,7 +1009,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_06_poe_off_and_materialized_columns_not_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_04_poe_off_and_materialized_columns_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -849,7 +1052,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_06_poe_off_and_materialized_columns_not_allowed_with_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_04_poe_off_and_materialized_columns_allowed_with_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -914,7 +1117,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_07_poe_off_and_materialized_columns_not_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_04_poe_off_and_materialized_columns_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -938,7 +1141,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -957,7 +1182,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_07_poe_off_and_materialized_columns_not_allowed_without_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_05_poe_off_and_materialized_columns_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -981,29 +1206,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1022,7 +1225,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_08_poe_v1_and_materialized_columns_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_05_poe_off_and_materialized_columns_allowed_without_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1046,7 +1249,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1065,7 +1290,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_08_poe_v1_and_materialized_columns_allowed_with_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_05_poe_off_and_materialized_columns_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1089,14 +1314,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.mat_pp_email, 'bla'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1115,7 +1355,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_09_poe_v1_and_materialized_columns_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_06_poe_off_and_materialized_columns_not_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1158,7 +1398,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_09_poe_v1_and_materialized_columns_allowed_without_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_06_poe_off_and_materialized_columns_not_allowed_with_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1182,14 +1422,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1208,7 +1463,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_06_poe_off_and_materialized_columns_not_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1232,7 +1487,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1251,7 +1528,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_07_poe_off_and_materialized_columns_not_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1275,14 +1552,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.mat_pp_email, 'bla'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1301,7 +1571,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_07_poe_off_and_materialized_columns_not_allowed_without_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1325,7 +1595,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1344,7 +1636,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_07_poe_off_and_materialized_columns_not_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1368,14 +1660,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1394,7 +1701,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_00_poe_v2_and_materialized_columns_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_08_poe_v1_and_materialized_columns_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1418,10 +1725,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1440,7 +1744,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_01_poe_v2_and_materialized_columns_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_08_poe_v1_and_materialized_columns_allowed_with_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1464,10 +1768,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.mat_pp_email, 'bla'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1486,7 +1794,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_02_poe_v2_and_materialized_columns_off_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_08_poe_v1_and_materialized_columns_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1510,10 +1818,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1532,7 +1844,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_03_poe_v2_and_materialized_columns_off_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_09_poe_v1_and_materialized_columns_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1556,10 +1868,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1578,7 +1887,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_04_poe_off_and_materialized_columns_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_09_poe_v1_and_materialized_columns_allowed_without_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1602,16 +1911,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1630,7 +1937,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_05_poe_off_and_materialized_columns_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_09_poe_v1_and_materialized_columns_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1654,16 +1961,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1682,7 +1987,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_06_poe_off_and_materialized_columns_not_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1706,16 +2011,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1734,7 +2030,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_07_poe_off_and_materialized_columns_not_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1758,16 +2054,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.mat_pp_email, 'bla'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1786,7 +2080,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_08_poe_v1_and_materialized_columns_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1810,16 +2104,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1838,7 +2130,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_09_poe_v1_and_materialized_columns_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1862,16 +2154,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1890,7 +2173,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1914,16 +2197,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, 'email'), ''), 'null'), '^"|"$', ''), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1942,7 +2223,7 @@use_hive_partitioning=0'''# ----# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization+# name: TestClickhouseSessionRecordingsListFromQuery.test_event_filter_with_person_properties_materialized_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -1966,16 +2247,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -1994,7 +2273,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_action_filter+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_00_poe_v2_and_materialized_columns_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2013,21 +2292,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2044,7 +2319,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_action_filter.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_00_poe_v2_and_materialized_columns_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2063,21 +2338,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2094,7 +2365,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_action_filter.2+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_01_poe_v2_and_materialized_columns_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2113,21 +2384,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`+ FROM events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2144,7 +2411,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_action_filter.3+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_01_poe_v2_and_materialized_columns_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2163,21 +2430,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2194,7 +2457,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_all_filters_at_once+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_02_poe_v2_and_materialized_columns_off_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2221,29 +2484,9 @@WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,(SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom-event'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2260,7 +2503,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_02_poe_v2_and_materialized_columns_off_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2279,21 +2522,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2310,7 +2549,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_03_poe_v2_and_materialized_columns_off_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2329,21 +2568,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`+ FROM events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2360,7 +2595,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties.2+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_03_poe_v2_and_materialized_columns_off_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2379,21 +2614,17 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2410,7 +2641,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_04_poe_off_and_materialized_columns_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2434,7 +2665,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -2453,7 +2693,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_active_sessions+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_04_poe_off_and_materialized_columns_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2477,9 +2717,18 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2496,7 +2745,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_active_sessions.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_05_poe_off_and_materialized_columns_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2520,9 +2769,18 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, '60'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2539,7 +2797,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_active_sessions.2+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_05_poe_off_and_materialized_columns_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2563,9 +2821,18 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(inactive_seconds, '60'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -2582,7 +2849,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_ordering+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_06_poe_off_and_materialized_columns_not_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2606,13 +2873,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY active_seconds DESC,+ ORDER BY start_time DESC,s.session_id DESC- LIMIT 4- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -2626,7 +2901,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_ordering.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_06_poe_off_and_materialized_columns_not_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2650,13 +2925,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY console_error_count DESC,+ ORDER BY start_time DESC,s.session_id DESC- LIMIT 4- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -2670,7 +2953,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_ordering.2+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_07_poe_off_and_materialized_columns_not_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2694,13 +2977,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 4- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -2714,7 +3005,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_paging+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_07_poe_off_and_materialized_columns_not_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2738,13 +3029,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 2- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -2758,7 +3057,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_paging.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_08_poe_v1_and_materialized_columns_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2782,13 +3081,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 2- OFFSET 1 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -2802,7 +3109,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_paging.2+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_08_poe_v1_and_materialized_columns_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2826,13 +3133,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 2- OFFSET 2 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -2846,7 +3161,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_09_poe_v1_and_materialized_columns_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2870,7 +3185,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -2889,7 +3213,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter.1+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_09_poe_v1_and_materialized_columns_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2913,7 +3237,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-30 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -2932,7 +3265,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter_respects_ttl_0_that_searching_from_28_days_ago_excludes_sessions_past_TTL+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2956,16 +3289,25 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-04 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))- GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY start_time DESC,- s.session_id DESC- LIMIT 51 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,max_bytes_before_external_group_by=0,transform_null_in=1,optimize_min_equality_disjunction_chain_length=4294967295,@@ -2975,7 +3317,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter_respects_ttl_1_that_searching_from_29_days_ago_still_excludes_sessions_past_TTL+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_10_poe_v1_and_not_materialized_columns_not_allowed_with_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -2999,7 +3341,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -3018,7 +3369,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter_respects_ttl_2_that_even_searching_from_30_days_ago_exactly_at_TTL_boundary_excludes_sessions_past_TTL+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3042,7 +3393,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', '') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$session_id'), ''), 'null'), '^"|"$', ''))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -3061,7 +3421,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_to_filter+# name: TestClickhouseSessionRecordingsListFromQuery.test_person_id_filter_11_poe_v1_and_not_materialized_columns_not_allowed_without_materialization[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3085,7 +3445,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-28 23:59:59.999999', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -3104,7 +3473,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_date_to_filter.1+# name: TestSessionRecordingsListFromQuery_0.test_action_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3123,14 +3492,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 12:46:00.000000', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3147,7 +3523,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_duration_filter+# name: TestSessionRecordingsListFromQuery_0.test_action_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3166,14 +3542,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3190,7 +3573,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_duration_filter.1+# name: TestSessionRecordingsListFromQuery_0.test_action_filter.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3209,14 +3592,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), less(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3233,7 +3623,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter+# name: TestSessionRecordingsListFromQuery_0.test_action_filter.3'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3252,21 +3642,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3283,7 +3673,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter.1+# name: TestSessionRecordingsListFromQuery_0.test_action_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3302,21 +3692,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3333,7 +3723,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_has_ttl_applied_too+# name: TestSessionRecordingsListFromQuery_0.test_action_filter[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3352,21 +3742,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3383,7 +3773,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_has_ttl_applied_too.1+# name: TestSessionRecordingsListFromQuery_0.test_action_filter[new_events_schema.3]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3402,14 +3792,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3426,7 +3823,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_active_sessions+# name: TestSessionRecordingsListFromQuery_0.test_action_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3445,21 +3842,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`)), and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3476,7 +3873,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_active_sessions.1+# name: TestSessionRecordingsListFromQuery_0.test_all_filters_at_once'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3500,16 +3897,32 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom-event'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3526,7 +3939,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter+# name: TestSessionRecordingsListFromQuery_0.test_all_filters_at_once[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3550,21 +3963,32 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 1))- GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom-event'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3581,7 +4005,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter.1+# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3600,26 +4024,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 1))- GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3636,7 +4055,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter.2+# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3655,26 +4074,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 2))- GROUP BY groups.group_type_index, groups.group_key) AS events__group_2 ON equals(events.`$group_2`, events__group_2.key)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_2.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3691,7 +4105,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded+# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3710,21 +4124,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3741,7 +4155,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded.1+# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3760,43 +4174,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3813,7 +4205,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded.2+# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3832,43 +4224,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3885,7 +4255,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_person_properties+# name: TestSessionRecordingsListFromQuery_0.test_any_event_filter_with_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3904,36 +4274,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'bla'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -3950,7 +4305,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_person_properties.1+# name: TestSessionRecordingsListFromQuery_0.test_basic_query'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -3974,29 +4329,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'something else'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4015,7 +4348,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_properties+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_active_sessions'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4039,16 +4372,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -4065,7 +4391,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_properties.1+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_active_sessions.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4089,16 +4415,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, '60'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -4115,7 +4434,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_matching_on_session_id+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_active_sessions.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4139,16 +4458,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(inactive_seconds, '60'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -4165,7 +4477,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_matching_on_session_id.1+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_ordering'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4189,19 +4501,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY start_time DESC,+ ORDER BY active_seconds DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 4+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -4215,7 +4521,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_ordering.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4239,19 +4545,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY start_time DESC,+ ORDER BY console_error_count DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 4+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -4265,7 +4565,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties.1+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_ordering.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4289,19 +4589,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 4+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -4315,7 +4609,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties.2+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_paging'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4339,19 +4633,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 2+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -4365,7 +4653,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties.3+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_paging.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4389,19 +4677,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Safari'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 2+ OFFSET 1 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -4415,7 +4697,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_test_accounts_excluded+# name: TestSessionRecordingsListFromQuery_0.test_basic_query_with_paging.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4439,83 +4721,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 2+ OFFSET 2 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -4529,7 +4741,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_test_accounts_excluded.1+# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4553,14 +4765,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4579,7 +4784,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_two_events_and_multiple_teams+# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4603,21 +4808,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageleave'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-30 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4636,7 +4827,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_0_single_distinct_id+# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter_respects_ttl_0_that_searching_from_28_days_ago_excludes_sessions_past_TTL'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4660,7 +4851,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-04 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4679,7 +4870,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_1_multiple_distinct_ids+# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter_respects_ttl_1_that_searching_from_29_days_ago_still_excludes_sessions_past_TTL'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4703,7 +4894,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1', 'test-user-2']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4722,7 +4913,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_2_non_existent_distinct_id+# name: TestSessionRecordingsListFromQuery_0.test_date_from_filter_respects_ttl_2_that_even_searching_from_30_days_ago_exactly_at_TTL_boundary_excludes_sessions_past_TTL'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4746,7 +4937,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['non-existent-user']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4765,7 +4956,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_3_empty_distinct_ids+# name: TestSessionRecordingsListFromQuery_0.test_date_to_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4789,7 +4980,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-28 23:59:59.999999', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -4808,7 +4999,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_0__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_0.test_date_to_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4827,20 +5018,14 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(or(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 12:46:00.000000', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -4857,7 +5042,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_1__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_0.test_duration_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4876,20 +5061,14 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -4906,7 +5085,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_2__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_0.test_duration_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4925,20 +5104,14 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), less(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -4955,7 +5128,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_3__key_level_value_info_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_0.test_event_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -4974,20 +5147,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(equals(console_logs_log_entries.level, 'info'), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5004,7 +5178,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library+# name: TestSessionRecordingsListFromQuery_0.test_event_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5028,9 +5202,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-ios'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5047,7 +5228,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5071,9 +5252,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-react-native'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5090,7 +5278,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_snapshot_source+# name: TestSessionRecordingsListFromQuery_0.test_event_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5114,9 +5302,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'web'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5133,7 +5328,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_snapshot_source.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_has_ttl_applied_too'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5157,9 +5352,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'mobile'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5176,7 +5378,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_errors+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_has_ttl_applied_too.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5195,20 +5397,14 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'error'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5225,7 +5421,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_errors.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_has_ttl_applied_too[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5244,20 +5440,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5274,7 +5471,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_logs+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_active_sessions'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5293,20 +5490,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5323,7 +5521,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_logs.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_active_sessions.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5342,20 +5540,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5372,7 +5571,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_logs_and_explicit_date_range+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_active_sessions[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5396,15 +5595,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), lessOrEquals(console_logs_log_entries.timestamp, toDateTime64('today', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5421,7 +5621,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_warns+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_active_sessions[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5440,20 +5640,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5470,7 +5671,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_warns.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5489,20 +5690,26 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5519,7 +5726,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_mixed_console_counts+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5538,20 +5745,26 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(in(console_logs_log_entries.level, tuple('warn', 'error')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5568,7 +5781,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_mixed_console_counts.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5587,20 +5800,26 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 2))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_2 ON equals(events.`$group_2`, events__group_2.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_2.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5617,7 +5836,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_on_session_ids+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5641,11 +5860,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999),- in(s.session_id,- ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],- greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),- lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -5664,7 +5891,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_on_session_ids.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5688,11 +5915,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999),- in(s.session_id,- ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],- greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),- lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 2))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_2 ON equals(events.`$group_2`, events__group_2.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_2.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -5711,71 +5946,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort- '''-- SELECT count(DISTINCT person_id)- FROM cohortpeople- WHERE team_id = 99999- AND cohort_id = 99999- AND version = 0- '''-# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort.1- '''-- SELECT DISTINCT p.id- FROM- (SELECT *- FROM person- JOIN- (SELECT id,- max(version) as version,- max(is_deleted) as is_deleted- FROM person- WHERE team_id = 99999- GROUP BY id) as person_max ON person.id = person_max.id- AND person.version = person_max.version- WHERE team_id = 99999- AND person_max.is_deleted = 0) AS p- 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 p.id = pdi.person_id- WHERE team_id = 99999- AND (pdi.distinct_id IN- (SELECT distinct_id- FROM- (SELECT person_distinct_ids.distinct_id AS distinct_id- FROM- (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,- person_distinct_id2.distinct_id AS distinct_id- FROM person_distinct_id2- WHERE equals(person_distinct_id2.team_id, 99999)- GROUP BY person_distinct_id2.distinct_id- HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.person_id, (- (SELECT persons.id AS id- FROM- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,- person.id AS id- FROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT where_optimization.id AS id- FROM person AS where_optimization- WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons- WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)- ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,- join_algorithm='auto')))- LIMIT 1000000000)))- '''-# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort.2+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_group_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5799,7 +5970,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -5818,7 +6001,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort.3+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5842,19 +6025,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,- (SELECT pdi.distinct_id AS distinct_id- FROM- (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted- FROM person_distinct_id2- WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))- GROUP BY person_distinct_id2.distinct_id- HAVING equals(is_deleted, 0)) AS pdi- LEFT JOIN- (SELECT cohortpeople.person_id AS person_id, 1 AS matched- FROM cohortpeople- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)- WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -5873,71 +6051,8011 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded.1'''-- SELECT count(DISTINCT person_id)- FROM cohortpeople- WHERE team_id = 99999- AND cohort_id = 99999- AND version = 0+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events.1+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded.2'''-- SELECT DISTINCT p.id- FROM- (SELECT *- FROM person- JOIN- (SELECT id,- max(version) as version,- max(is_deleted) as is_deleted- FROM person- WHERE team_id = 99999- GROUP BY id) as person_max ON person.id = person_max.id- AND person.version = person_max.version- WHERE team_id = 99999- AND person_max.is_deleted = 0) AS p- 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 p.id = pdi.person_id- WHERE team_id = 99999- AND (pdi.distinct_id IN- (SELECT distinct_id- FROM- (SELECT person_distinct_ids.distinct_id AS distinct_id- FROM- (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,- person_distinct_id2.distinct_id AS distinct_id- FROM person_distinct_id2- WHERE equals(person_distinct_id2.team_id, 99999)- GROUP BY person_distinct_id2.distinct_id- HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.person_id, (- (SELECT persons.id AS id- FROM- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,- person.id AS id- FROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT where_optimization.id AS id- FROM person AS where_optimization- WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons- WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)- ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,- join_algorithm='auto')))- LIMIT 1000000000)))+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_event_properties_test_accounts_excluded[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_person_properties+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'bla'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_person_properties.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'something else'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_person_properties[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'something else'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_person_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'bla'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_properties+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_properties.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_properties[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_hogql_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_matching_on_session_id+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_matching_on_session_id.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_matching_on_session_id[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_matching_on_session_id[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties.3+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Safari'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties[new_events_schema.3]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), and(equals(events.properties.`$browser`, 'Safari'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_test_accounts_excluded+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_test_accounts_excluded.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_test_accounts_excluded[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_test_accounts_excluded[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_two_events_and_multiple_teams+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageleave'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_event_filter_with_two_events_and_multiple_teams[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageleave'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_0_single_distinct_id+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_1_multiple_distinct_ids+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1', 'test-user-2']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_2_non_existent_distinct_id+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['non-existent-user']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_by_distinct_ids_3_empty_distinct_ids+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_0__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(or(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_1__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_2__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_console_text_3__key_level_value_info_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(equals(console_logs_log_entries.level, 'info'), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-ios'))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-react-native'))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_snapshot_source+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'web'))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_by_snapshot_source.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'mobile'))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_errors+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'error'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_errors.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_logs+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_logs.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_logs_and_explicit_date_range+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), lessOrEquals(console_logs_log_entries.timestamp, toDateTime64('today', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_warns+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_console_warns.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_mixed_console_counts+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(in(console_logs_log_entries.level, tuple('warn', 'error')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_for_recordings_with_mixed_console_counts.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_on_session_ids+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999),+ in(s.session_id,+ ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],+ greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),+ lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_on_session_ids.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999),+ in(s.session_id,+ ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],+ greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),+ lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort+ '''++ SELECT count(DISTINCT person_id)+ FROM cohortpeople+ WHERE team_id = 99999+ AND cohort_id = 99999+ AND version = 0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort.1+ '''++ SELECT DISTINCT p.id+ FROM+ (SELECT *+ FROM person+ JOIN+ (SELECT id,+ max(version) as version,+ max(is_deleted) as is_deleted+ FROM person+ WHERE team_id = 99999+ GROUP BY id) as person_max ON person.id = person_max.id+ AND person.version = person_max.version+ WHERE team_id = 99999+ AND person_max.is_deleted = 0) AS p+ 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 p.id = pdi.person_id+ WHERE team_id = 99999+ AND (pdi.distinct_id IN+ (SELECT distinct_id+ FROM+ (SELECT person_distinct_ids.distinct_id AS distinct_id+ FROM+ (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,+ person_distinct_id2.distinct_id AS distinct_id+ FROM person_distinct_id2+ WHERE equals(person_distinct_id2.team_id, 99999)+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids+ WHERE in(person_distinct_ids.person_id, (+ (SELECT persons.id AS id+ FROM+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,+ person.id AS id+ FROM person+ WHERE and(equals(person.team_id, 99999), in(id,+ (SELECT where_optimization.id AS id+ FROM person AS where_optimization+ WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons+ WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)+ ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto')))+ LIMIT 1000000000)))+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort.3+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events+ '''++ SELECT count(DISTINCT person_id)+ FROM cohortpeople+ WHERE team_id = 99999+ AND cohort_id = 99999+ AND version = 0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events.1+ '''++ SELECT DISTINCT p.id+ FROM+ (SELECT *+ FROM person+ JOIN+ (SELECT id,+ max(version) as version,+ max(is_deleted) as is_deleted+ FROM person+ WHERE team_id = 99999+ GROUP BY id) as person_max ON person.id = person_max.id+ AND person.version = person_max.version+ WHERE team_id = 99999+ AND person_max.is_deleted = 0) AS p+ 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 p.id = pdi.person_id+ WHERE team_id = 99999+ AND (pdi.distinct_id IN+ (SELECT distinct_id+ FROM+ (SELECT person_distinct_ids.distinct_id AS distinct_id+ FROM+ (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,+ person_distinct_id2.distinct_id AS distinct_id+ FROM person_distinct_id2+ WHERE equals(person_distinct_id2.team_id, 99999)+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids+ WHERE in(person_distinct_ids.person_id, (+ (SELECT persons.id AS id+ FROM+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,+ person.id AS id+ FROM person+ WHERE and(equals(person.team_id, 99999), in(id,+ (SELECT where_optimization.id AS id+ FROM person AS where_optimization+ WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons+ WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)+ ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto')))+ LIMIT 1000000000)))+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events.3+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_with_person_properties_exact+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_with_person_properties_exact[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_with_person_properties_not_contains+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_filter_with_person_properties_not_contains[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_listing_ignores_future_replays+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-08-30 11:55:01.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-08-27 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.3+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'bar'), ''), 'null'), '^"|"$', ''), 'foo'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.4+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.5+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters[new_events_schema.3]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^bar), '{}'), toJSONString(events.properties.^bar), if(isNull(events.properties.bar), NULL, if(startsWith(dynamicType(events.properties.bar), 'DateTime'), replaceOne(toString(events.properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.bar), 'Array'), startsWith(dynamicType(events.properties.bar), 'Map'), startsWith(dynamicType(events.properties.bar), 'Tuple')), toJSONString(events.properties.bar), toString(events.properties.bar))))), 'foo'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters[new_events_schema.4]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters[new_events_schema.5]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_event_filters+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_event_filters.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_event_filters[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_event_filters[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_0__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_1__key_level_value_info_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(equals(console_logs_log_entries.level, 'info'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_2__key_level_value_warn_operator_exact_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_3__key_message_value_random_operator_exact_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.message, 'random'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_4__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(or(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_one']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_one']))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters.3+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_two']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_two']))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_one']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(events.properties.`$session_id`, ['session_id_one']))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters[new_events_schema.3]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_two']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(events.properties.`$session_id`, ['session_id_two']))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_person_filters+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_person_filters.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_person_filters[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_operand_or_person_filters[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_ordering+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_ordering.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY mouse_activity_count DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_person_id_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_person_id_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_person_profile_finds_anonymous_distinct_id_sessions+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), or(in(s.distinct_id, ['identified-user']), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_person_profile_finds_anonymous_distinct_id_sessions[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), or(in(s.distinct_id, ['identified-user']), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_recording_property_in_properties_is_routed_to_having_predicates+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_sessions_with_current_data+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_host_property_test_account_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_host_property_test_account_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_host_property_test_account_filter[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(events.properties.`$host`), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_host_property_test_account_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter_allowing_denormalized_props+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter_allowing_denormalized_props.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter_allowing_denormalized_props[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter_allowing_denormalized_props[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_event_property_test_account_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_event_property_test_account_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_event_property_test_account_filter[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_event_property_test_account_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_person_property_test_account_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_person_property_test_account_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_person_property_test_account_filter[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_person_property_test_account_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_person_property_test_account_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_person_property_test_account_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_person_property_test_account_filter[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_0.test_top_level_person_property_test_account_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter.3+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter[new_events_schema.3]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_action_filter[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`)), and(equals(events.properties.`$session_id`, 'test_action_filter-session-one'), isNotNull(events.properties.`$session_id`)), and(equals(events.properties.`$window_id`, 'test_action_filter-window-id'), isNotNull(events.properties.`$window_id`)))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_all_filters_at_once+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom-event'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_all_filters_at_once[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom-event'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_basic_query+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events.2+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_active_sessions'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -5961,9 +14079,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -5980,7 +14098,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_users_from_excluded_cohort_no_events.3+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_active_sessions.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6004,21 +14122,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,- (SELECT pdi.distinct_id AS distinct_id- FROM- (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted- FROM person_distinct_id2- WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))- GROUP BY person_distinct_id2.distinct_id- HAVING equals(is_deleted, 0)) AS pdi- LEFT JOIN- (SELECT cohortpeople.person_id AS person_id, 1 AS matched- FROM cohortpeople- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)- WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, '60'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -6035,7 +14141,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_with_person_properties_exact+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_active_sessions.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6059,31 +14165,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(inactive_seconds, '60'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -6100,7 +14184,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_filter_with_person_properties_not_contains+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_ordering'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6124,32 +14208,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY start_time DESC,+ ORDER BY active_seconds DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 4+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -6163,7 +14228,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_listing_ignores_future_replays+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_ordering.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6182,17 +14247,62 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-08-30 11:55:01.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-08-27 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY console_error_count DESC,+ s.session_id DESC+ LIMIT 4+ OFFSET 0 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_ordering.2+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 4+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -6206,7 +14316,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_paging'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6230,26 +14340,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 2+ OFFSET 0 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -6263,7 +14360,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_paging.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6287,26 +14384,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 2+ OFFSET 1 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -6320,7 +14404,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.2+# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_paging.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6344,26 +14428,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 51 SETTINGS readonly=2,+ LIMIT 2+ OFFSET 2 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -6377,7 +14448,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.3+# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6401,21 +14472,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'bar'), ''), 'null'), '^"|"$', ''), 'foo'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6434,7 +14491,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.4+# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6458,21 +14515,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-30 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6491,7 +14534,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_multiple_event_filters.5+# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter_respects_ttl_0_that_searching_from_28_days_ago_excludes_sessions_past_TTL'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6515,21 +14558,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-04 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6548,7 +14577,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_event_filters+# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter_respects_ttl_1_that_searching_from_29_days_ago_still_excludes_sessions_past_TTL'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6572,21 +14601,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6605,7 +14620,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_event_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter_respects_ttl_2_that_even_searching_from_30_days_ago_exactly_at_TTL_boundary_excludes_sessions_past_TTL'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6629,21 +14644,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6662,7 +14663,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_0__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_date_to_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6686,13 +14687,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-28 23:59:59.999999', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6711,7 +14706,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_1__key_level_value_info_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_date_to_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6735,13 +14730,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(equals(console_logs_log_entries.level, 'info'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 12:46:00.000000', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6760,7 +14749,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_2__key_level_value_warn_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_duration_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6784,15 +14773,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -6809,7 +14792,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_3__key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_duration_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6833,15 +14816,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.message, 'random'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), less(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -6858,7 +14835,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_filters_4__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_event_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6882,13 +14859,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(or(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6907,7 +14885,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters+# name: TestSessionRecordingsListFromQuery_1.test_event_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6931,23 +14909,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -6966,7 +14935,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -6990,23 +14959,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7025,7 +14985,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters.2+# name: TestSessionRecordingsListFromQuery_1.test_event_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7049,14 +15009,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_one']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_one']))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7075,7 +15035,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_mandatory_filters.3+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_has_ttl_applied_too'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7099,14 +15059,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_two']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_two']))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7125,7 +15085,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_person_filters+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_has_ttl_applied_too.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7135,65 +15095,21 @@dateDiff('SECOND', start_time, end_time) AS duration,argMinMerge(s.first_url) AS first_url,sum(s.click_count) AS click_count,- sum(s.keypress_count) AS keypress_count,- sum(s.mouse_activity_count) AS mouse_activity_count,- divide(sum(s.active_milliseconds), 1000) AS active_seconds,- minus(duration, active_seconds) AS inactive_seconds,- sum(s.console_log_count) AS console_log_count,- sum(s.console_warn_count) AS console_warn_count,- sum(s.console_error_count) AS console_error_count,- max(s.retention_period_days) AS retention_period_days,- plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,- round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,- coalesce(max(s.surfacing_score), 0.36) AS surfacing_score- FROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7212,7 +15128,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_operand_or_person_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_has_ttl_applied_too[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7236,51 +15152,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7299,7 +15178,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_ordering+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_active_sessions'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7323,9 +15202,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -7342,7 +15228,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_ordering.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_active_sessions.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7366,10 +15252,17 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY mouse_activity_count DESC,+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, 60.0))+ ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,max_execution_time=60,@@ -7385,7 +15278,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_person_id_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_active_sessions[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7409,18 +15302,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -7437,7 +15328,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_person_profile_finds_anonymous_distinct_id_sessions+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_active_sessions[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7461,18 +15352,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), or(in(s.distinct_id, ['identified-user']), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -7489,7 +15378,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_recording_property_in_properties_is_routed_to_having_predicates+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7513,9 +15402,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -7532,7 +15433,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_sessions_with_current_data+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7556,7 +15457,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7575,7 +15488,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_host_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7602,7 +15515,12 @@WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 2))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_2 ON equals(events.`$group_2`, events__group_2.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_2.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC@@ -7625,7 +15543,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_host_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7650,18 +15568,18 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7680,7 +15598,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7705,10 +15623,15 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 2))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_2 ON equals(events.`$group_2`, events__group_2.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_2.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -7730,7 +15653,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7755,10 +15678,15 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -7780,7 +15708,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter_allowing_denormalized_props+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7830,7 +15758,79 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_event_property_test_account_filter_allowing_denormalized_props.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7854,14 +15854,36 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7880,7 +15902,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_event_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7904,14 +15926,36 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7930,7 +15974,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_event_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -7954,14 +15998,36 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -7980,7 +16046,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_person_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8005,10 +16071,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -8030,7 +16096,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_hogql_person_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_person_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8072,7 +16138,7 @@WHERE equals(person.team_id, 99999)GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'bla'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC@@ -8095,7 +16161,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_person_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_person_properties.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8119,14 +16185,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'something else'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -8145,7 +16226,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_0.test_top_level_person_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_person_properties[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8170,8 +16251,8 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS eventsLEFT OUTER JOIN(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_idFROM person_distinct_id_overrides@@ -8187,8 +16268,8 @@WHERE equals(person.team_id, 99999)GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'something else'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -8210,7 +16291,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_action_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_person_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8229,21 +16310,36 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'bla'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8260,7 +16356,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_action_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8279,21 +16375,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8310,7 +16406,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_action_filter.2+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_properties.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8329,21 +16425,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8360,7 +16456,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_action_filter.3+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_properties[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8379,21 +16475,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-01-03 23:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(equals(events.`$session_id`, 'test_action_filter-session-one'), equals(events.`$window_id`, 'test_action_filter-window-id'))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2022-12-31 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8410,7 +16506,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_all_filters_at_once+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8434,32 +16530,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom-event'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8476,7 +16556,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_matching_on_session_id'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8495,21 +16575,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8526,7 +16606,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_matching_on_session_id.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8545,21 +16625,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8576,7 +16656,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_any_event_filter_with_properties.2+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_matching_on_session_id[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8595,21 +16675,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8626,7 +16706,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_matching_on_session_id[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8650,7 +16730,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -8669,7 +16756,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_active_sessions+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8693,9 +16780,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8712,7 +16806,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_active_sessions.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8736,9 +16830,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, '60'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8755,7 +16856,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_active_sessions.2+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8779,9 +16880,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(inactive_seconds, '60'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -8798,7 +16906,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_ordering+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties.3'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8822,13 +16930,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Safari'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY active_seconds DESC,+ ORDER BY start_time DESC,s.session_id DESC- LIMIT 4- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -8842,7 +16956,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_ordering.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8866,13 +16980,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Firefox'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY console_error_count DESC,+ ORDER BY start_time DESC,s.session_id DESC- LIMIT 4- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -8886,7 +17006,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_ordering.2+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8910,13 +17030,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 4- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -8930,7 +17056,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_paging+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties[new_events_schema.3]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8954,13 +17080,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), and(equals(events.properties.`$browser`, 'Safari'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 2- OFFSET 0 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -8974,7 +17106,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_paging.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -8998,13 +17130,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 2- OFFSET 1 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -9018,7 +17156,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_basic_query_with_paging.2+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_test_accounts_excluded'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9042,13 +17180,83 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESC- LIMIT 2- OFFSET 2 SETTINGS readonly=2,+ LIMIT 51 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,max_ast_elements=4000000,@@ -9062,7 +17270,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_test_accounts_excluded.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9086,7 +17294,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9105,7 +17320,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_test_accounts_excluded[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9129,7 +17344,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-30 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9148,7 +17370,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter_respects_ttl_0_that_searching_from_28_days_ago_excludes_sessions_past_TTL+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_test_accounts_excluded[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9172,7 +17394,78 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-04 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.properties.`$browser`, 'Chrome'), isNotNull(events.properties.`$browser`)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9191,7 +17484,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter_respects_ttl_1_that_searching_from_29_days_ago_still_excludes_sessions_past_TTL+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_two_events_and_multiple_teams'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9215,7 +17508,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageleave'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9234,7 +17541,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_from_filter_respects_ttl_2_that_even_searching_from_30_days_ago_exactly_at_TTL_boundary_excludes_sessions_past_TTL+# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_two_events_and_multiple_teams[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9258,7 +17565,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageleave'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9277,7 +17598,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_to_filter+# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_0_single_distinct_id'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9301,7 +17622,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-28 23:59:59.999999', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9320,7 +17641,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_date_to_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_1_multiple_distinct_ids'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9344,7 +17665,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 12:46:00.000000', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1', 'test-user-2']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -9363,7 +17684,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_duration_filter+# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_2_non_existent_distinct_id'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9387,9 +17708,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['non-existent-user']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9406,7 +17727,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_duration_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_3_empty_distinct_ids'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9432,7 +17753,7 @@FROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), less(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9449,7 +17770,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_0__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9468,21 +17789,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(or(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9499,7 +17819,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_1__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9518,21 +17838,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9549,7 +17868,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_has_ttl_applied_too+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_2__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9568,21 +17887,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9599,7 +17917,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_has_ttl_applied_too.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_3__key_level_value_info_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9618,14 +17936,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(equals(console_logs_log_entries.level, 'info'), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9642,7 +17966,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_active_sessions+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9666,16 +17990,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-ios'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9692,7 +18009,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_active_sessions.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9716,16 +18033,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(active_seconds, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-react-native'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9742,7 +18052,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_snapshot_source'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9766,21 +18076,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 1))- GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'web'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9797,7 +18095,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_snapshot_source.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9821,21 +18119,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 1))- GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'mobile'))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9852,7 +18138,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_group_filter.2+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_errors'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9871,26 +18157,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT JOIN- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'name'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___name, groups.group_type_index AS index, groups.group_key AS key- FROM groups- WHERE and(equals(groups.team_id, 99999), equals(index, 2))- GROUP BY groups.group_type_index, groups.group_key) AS events__group_2 ON equals(events.`$group_2`, events__group_2.key)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_2.properties___name, 'org one'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'error'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9907,7 +18187,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_errors.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9926,21 +18206,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -9957,7 +18236,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_logs'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -9976,43 +18255,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10029,7 +18285,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_event_properties_test_accounts_excluded.2+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_logs.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10048,43 +18304,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10101,7 +18334,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_person_properties+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_logs_and_explicit_date_range'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10125,29 +18358,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'bla'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), lessOrEquals(console_logs_log_entries.timestamp, toDateTime64('today', 6, 'UTC'))))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10166,7 +18383,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_person_properties.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_warns'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10181,40 +18398,24 @@divide(sum(s.active_milliseconds), 1000) AS active_seconds,minus(duration, active_seconds) AS inactive_seconds,sum(s.console_log_count) AS console_log_count,- sum(s.console_warn_count) AS console_warn_count,- sum(s.console_error_count) AS console_error_count,- max(s.retention_period_days) AS retention_period_days,- plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,- round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,- coalesce(max(s.surfacing_score), 0.36) AS surfacing_score- FROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__person.properties___email, 'something else'), 0)), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10231,7 +18432,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_properties+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_warns.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10250,21 +18451,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10281,7 +18481,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_hogql_properties.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_mixed_console_counts'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10300,21 +18500,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(in(console_logs_log_entries.level, tuple('warn', 'error')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10331,7 +18530,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_matching_on_session_id+# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_mixed_console_counts.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10350,21 +18549,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10381,7 +18579,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_matching_on_session_id.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_on_session_ids'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10405,14 +18603,11 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$autocapture'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999),+ in(s.session_id,+ ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],+ greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),+ lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10431,7 +18626,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties+# name: TestSessionRecordingsListFromQuery_1.test_filter_on_session_ids.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10455,14 +18650,11 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999),+ in(s.session_id,+ ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],+ greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),+ lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10481,7 +18673,71 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort+ '''++ SELECT count(DISTINCT person_id)+ FROM cohortpeople+ WHERE team_id = 99999+ AND cohort_id = 99999+ AND version = 0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort.1+ '''++ SELECT DISTINCT p.id+ FROM+ (SELECT *+ FROM person+ JOIN+ (SELECT id,+ max(version) as version,+ max(is_deleted) as is_deleted+ FROM person+ WHERE team_id = 99999+ GROUP BY id) as person_max ON person.id = person_max.id+ AND person.version = person_max.version+ WHERE team_id = 99999+ AND person_max.is_deleted = 0) AS p+ 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 p.id = pdi.person_id+ WHERE team_id = 99999+ AND (pdi.distinct_id IN+ (SELECT distinct_id+ FROM+ (SELECT person_distinct_ids.distinct_id AS distinct_id+ FROM+ (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,+ person_distinct_id2.distinct_id AS distinct_id+ FROM person_distinct_id2+ WHERE equals(person_distinct_id2.team_id, 99999)+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids+ WHERE in(person_distinct_ids.person_id, (+ (SELECT persons.id AS id+ FROM+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,+ person.id AS id+ FROM person+ WHERE and(equals(person.team_id, 99999), in(id,+ (SELECT where_optimization.id AS id+ FROM person AS where_optimization+ WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons+ WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)+ ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto')))+ LIMIT 1000000000)))+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10505,14 +18761,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10531,7 +18780,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties.2+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort.3'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10555,14 +18804,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10581,7 +18835,71 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_properties.3+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events+ '''++ SELECT count(DISTINCT person_id)+ FROM cohortpeople+ WHERE team_id = 99999+ AND cohort_id = 99999+ AND version = 0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events.1+ '''++ SELECT DISTINCT p.id+ FROM+ (SELECT *+ FROM person+ JOIN+ (SELECT id,+ max(version) as version,+ max(is_deleted) as is_deleted+ FROM person+ WHERE team_id = 99999+ GROUP BY id) as person_max ON person.id = person_max.id+ AND person.version = person_max.version+ WHERE team_id = 99999+ AND person_max.is_deleted = 0) AS p+ 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 p.id = pdi.person_id+ WHERE team_id = 99999+ AND (pdi.distinct_id IN+ (SELECT distinct_id+ FROM+ (SELECT person_distinct_ids.distinct_id AS distinct_id+ FROM+ (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,+ person_distinct_id2.distinct_id AS distinct_id+ FROM person_distinct_id2+ WHERE equals(person_distinct_id2.team_id, 99999)+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids+ WHERE in(person_distinct_ids.person_id, (+ (SELECT persons.id AS id+ FROM+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,+ person.id AS id+ FROM person+ WHERE and(equals(person.team_id, 99999), in(id,+ (SELECT where_optimization.id AS id+ FROM person AS where_optimization+ WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons+ WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)+ ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,+ join_algorithm='auto')))+ LIMIT 1000000000)))+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10605,14 +18923,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Safari'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10631,7 +18942,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_test_accounts_excluded+# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events.3'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10655,78 +18966,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING equals(countIf(ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0)), 0)- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10745,7 +18997,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_test_accounts_excluded.1+# name: TestSessionRecordingsListFromQuery_1.test_filter_with_person_properties_exact'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10769,14 +19021,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10795,7 +19062,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_event_filter_with_two_events_and_multiple_teams+# name: TestSessionRecordingsListFromQuery_1.test_filter_with_person_properties_exact[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10819,21 +19086,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageleave'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10852,7 +19127,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_0_single_distinct_id+# name: TestSessionRecordingsListFromQuery_1.test_filter_with_person_properties_not_contains'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10876,7 +19151,27 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10895,7 +19190,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_1_multiple_distinct_ids+# name: TestSessionRecordingsListFromQuery_1.test_filter_with_person_properties_not_contains[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10919,7 +19214,27 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['test-user-1', 'test-user-2']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -10938,7 +19253,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_2_non_existent_distinct_id+# name: TestSessionRecordingsListFromQuery_1.test_listing_ignores_future_replays'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -10957,14 +19272,14 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-08-30 11:55:01.000000', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.distinct_id, ['non-existent-user']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-08-27 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -10981,7 +19296,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_by_distinct_ids_3_empty_distinct_ids+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11005,7 +19320,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -11024,7 +19353,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_0__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11043,20 +19372,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(or(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11073,7 +19410,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_1__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_4_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11092,20 +19429,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 4%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11122,7 +19467,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_2__key_level_value_warn_error_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.3'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11141,20 +19486,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(in(console_logs_log_entries.level, tuple('warn', 'error')), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'bar'), ''), 'null'), '^"|"$', ''), 'foo'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11171,7 +19524,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_console_text_3__key_level_value_info_operator_exact_type_log_entry_key_message_value_message_5_operator_icontains_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.4'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11190,20 +19543,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(equals(console_logs_log_entries.level, 'info'), ilike(toString(console_logs_log_entries.message), '%message 5%')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11220,7 +19581,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.5'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11244,9 +19605,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-ios'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11263,7 +19638,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_lib_event_property_converts_to_snapshot_library.1+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11287,9 +19662,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_library), 'posthog-react-native'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11306,7 +19695,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_snapshot_source+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11330,9 +19719,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'web'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11349,7 +19752,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_by_snapshot_source.1+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters[new_events_schema.3]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11373,9 +19776,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^bar), '{}'), toJSONString(events.properties.^bar), if(isNull(events.properties.bar), NULL, if(startsWith(dynamicType(events.properties.bar), 'DateTime'), replaceOne(toString(events.properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.bar), 'Array'), startsWith(dynamicType(events.properties.bar), 'Map'), startsWith(dynamicType(events.properties.bar), 'Tuple')), toJSONString(events.properties.bar), toString(events.properties.bar))))), 'foo'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), equals(argMinMerge(s.snapshot_source), 'mobile'))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11392,7 +19809,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_errors+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters[new_events_schema.4]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11411,20 +19828,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'error'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11441,7 +19866,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_errors.1+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters[new_events_schema.5]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11460,20 +19885,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(if(notEquals(toJSONString(events.properties.^foo), '{}'), toJSONString(events.properties.^foo), if(isNull(events.properties.foo), NULL, if(startsWith(dynamicType(events.properties.foo), 'DateTime'), replaceOne(toString(events.properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.foo), 'Array'), startsWith(dynamicType(events.properties.foo), 'Map'), startsWith(dynamicType(events.properties.foo), 'Tuple')), toJSONString(events.properties.foo), toString(events.properties.foo))))), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11490,7 +19923,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_logs+# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11509,20 +19942,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11539,7 +19980,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_logs.1+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_event_filters'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11558,20 +19999,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11588,7 +20037,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_logs_and_explicit_date_range+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_event_filters.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11612,13 +20061,21 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), lessOrEquals(console_logs_log_entries.timestamp, toDateTime64('today', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -11637,7 +20094,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_warns+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_event_filters[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11656,20 +20113,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11686,7 +20151,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_console_warns.1+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_event_filters[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11705,20 +20170,28 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11735,7 +20208,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_mixed_console_counts+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_0__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11754,20 +20227,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(in(console_logs_log_entries.level, tuple('warn', 'error')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11784,7 +20257,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_for_recordings_with_mixed_console_counts.1+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_1__key_level_value_info_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11803,20 +20276,20 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-01-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'info'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(and(equals(console_logs_log_entries.level, 'info'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -11833,7 +20306,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_on_session_ids+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_2__key_level_value_warn_operator_exact_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11857,11 +20330,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999),- in(s.session_id,- ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],- greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),- lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -11880,7 +20355,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_on_session_ids.1+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_3__key_message_value_random_operator_exact_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -11904,11 +20379,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999),- in(s.session_id,- ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],- greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')),- lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(equals(console_logs_log_entries.message, 'random'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -11927,71 +20404,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort- '''-- SELECT count(DISTINCT person_id)- FROM cohortpeople- WHERE team_id = 99999- AND cohort_id = 99999- AND version = 0- '''-# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort.1- '''-- SELECT DISTINCT p.id- FROM- (SELECT *- FROM person- JOIN- (SELECT id,- max(version) as version,- max(is_deleted) as is_deleted- FROM person- WHERE team_id = 99999- GROUP BY id) as person_max ON person.id = person_max.id- AND person.version = person_max.version- WHERE team_id = 99999- AND person_max.is_deleted = 0) AS p- 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 p.id = pdi.person_id- WHERE team_id = 99999- AND (pdi.distinct_id IN- (SELECT distinct_id- FROM- (SELECT person_distinct_ids.distinct_id AS distinct_id- FROM- (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,- person_distinct_id2.distinct_id AS distinct_id- FROM person_distinct_id2- WHERE equals(person_distinct_id2.team_id, 99999)- GROUP BY person_distinct_id2.distinct_id- HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.person_id, (- (SELECT persons.id AS id- FROM- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,- person.id AS id- FROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT where_optimization.id AS id- FROM person AS where_optimization- WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons- WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)- ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,- join_algorithm='auto')))- LIMIT 1000000000)))- '''-# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort.2+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_4__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12015,7 +20428,13 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,+ (SELECT console_logs_log_entries.log_source_id AS log_source_id+ FROM+ (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp+ FROM log_entries+ WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries+ WHERE and(or(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12034,7 +20453,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort.3+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12058,19 +20477,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,- (SELECT pdi.distinct_id AS distinct_id- FROM- (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted- FROM person_distinct_id2- WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))- GROUP BY person_distinct_id2.distinct_id- HAVING equals(is_deleted, 0)) AS pdi- LEFT JOIN- (SELECT cohortpeople.person_id AS person_id, 1 AS matched- FROM cohortpeople- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)- WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12089,71 +20512,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events- '''-- SELECT count(DISTINCT person_id)- FROM cohortpeople- WHERE team_id = 99999- AND cohort_id = 99999- AND version = 0- '''-# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events.1- '''-- SELECT DISTINCT p.id- FROM- (SELECT *- FROM person- JOIN- (SELECT id,- max(version) as version,- max(is_deleted) as is_deleted- FROM person- WHERE team_id = 99999- GROUP BY id) as person_max ON person.id = person_max.id- AND person.version = person_max.version- WHERE team_id = 99999- AND person_max.is_deleted = 0) AS p- 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 p.id = pdi.person_id- WHERE team_id = 99999- AND (pdi.distinct_id IN- (SELECT distinct_id- FROM- (SELECT person_distinct_ids.distinct_id AS distinct_id- FROM- (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id,- person_distinct_id2.distinct_id AS distinct_id- FROM person_distinct_id2- WHERE equals(person_distinct_id2.team_id, 99999)- GROUP BY person_distinct_id2.distinct_id- HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids- WHERE in(person_distinct_ids.person_id, (- (SELECT persons.id AS id- FROM- (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$is_internal'), ''), 'null'), '^"|"$', '')), person.version), 1) AS `properties___$is_internal`,- person.id AS id- FROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT where_optimization.id AS id- FROM person AS where_optimization- WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, '$is_internal'), ''), 'null'), '^"|"$', ''), 'yes'), 0)))))- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons- WHERE ifNull(equals(persons.`properties___$is_internal`, 'yes'), 0)- ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1,- join_algorithm='auto')))- LIMIT 1000000000)))- '''-# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events.2+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12177,7 +20536,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12196,7 +20571,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_users_from_excluded_cohort_no_events.3+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters.2'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12220,19 +20595,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.distinct_id,- (SELECT pdi.distinct_id AS distinct_id- FROM- (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted- FROM person_distinct_id2- WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))- GROUP BY person_distinct_id2.distinct_id- HAVING equals(is_deleted, 0)) AS pdi- LEFT JOIN- (SELECT cohortpeople.person_id AS person_id, 1 AS matched- FROM cohortpeople- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)- WHERE notEquals(ifNull(cohort_0.matched, 0), 1))))+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_one']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_one']))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12251,7 +20621,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_with_person_properties_exact+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters.3'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12275,29 +20645,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_two']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_two']))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12316,7 +20671,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_filter_with_person_properties_not_contains+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12340,27 +20695,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(ilike(toString(events__person.properties___email), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12379,7 +20730,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_listing_ignores_future_replays+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters[new_events_schema.2]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12398,14 +20749,21 @@sum(s.console_error_count) AS console_error_count,max(s.retention_period_days) AS retention_period_days,plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-08-30 11:55:01.000000', 6, 'UTC')) AS ongoing,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2023-08-27 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_one']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(events.properties.`$session_id`, ['session_id_one']))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2023-08-30 12:00:01.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -12422,7 +20780,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters[new_events_schema.3]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12446,21 +20804,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_two']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(events.properties.`$session_id`, ['session_id_two']))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12479,7 +20830,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12503,21 +20854,23 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12536,7 +20889,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.2+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_person_filters'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12547,34 +20900,64 @@argMinMerge(s.first_url) AS first_url,sum(s.click_count) AS click_count,sum(s.keypress_count) AS keypress_count,- sum(s.mouse_activity_count) AS mouse_activity_count,- divide(sum(s.active_milliseconds), 1000) AS active_seconds,- minus(duration, active_seconds) AS inactive_seconds,- sum(s.console_log_count) AS console_log_count,- sum(s.console_warn_count) AS console_warn_count,- sum(s.console_error_count) AS console_error_count,- max(s.retention_period_days) AS retention_period_days,- plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,- dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,- greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,- round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,- coalesce(max(s.surfacing_score), 0.36) AS surfacing_score- FROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'new-event2'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12593,7 +20976,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.3+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_person_filters.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12617,17 +21000,47 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)), globalIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'bar'), ''), 'null'), '^"|"$', ''), 'foo'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC@@ -12650,7 +21063,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.4+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_person_filters[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12674,18 +21087,48 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000))))@@ -12707,7 +21150,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_multiple_event_filters.5+# name: TestSessionRecordingsListFromQuery_1.test_operand_or_person_filters[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12731,21 +21174,51 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12764,7 +21237,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_event_filters+# name: TestSessionRecordingsListFromQuery_1.test_ordering'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12788,21 +21261,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12821,7 +21280,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_event_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_ordering.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12845,24 +21304,10 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY start_time DESC,+ ORDER BY mouse_activity_count DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,max_execution_time=60,@@ -12878,7 +21323,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_0__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_person_id_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12902,13 +21347,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12927,7 +21375,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_1__key_level_value_info_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_person_id_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -12950,14 +21398,17 @@greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_score- FROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(and(equals(console_logs_log_entries.level, 'info'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`)))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -12976,7 +21427,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_2__key_level_value_warn_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_person_profile_finds_anonymous_distinct_id_sessions'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13000,13 +21451,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.level, 'warn'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), or(in(s.distinct_id, ['identified-user']), globalIn(s.session_id,+ (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13025,7 +21479,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_3__key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_person_profile_finds_anonymous_distinct_id_sessions[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13049,13 +21503,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(equals(console_logs_log_entries.message, 'random'), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), or(in(s.distinct_id, ['identified-user']), globalIn(s.session_id,+ (SELECT DISTINCT events.properties.`$session_id` AS `$session_id`+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(events.properties.`$session_id`))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13074,7 +21531,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_filters_4__key_level_value_warn_operator_exact_type_log_entry_key_message_value_random_operator_exact_type_log_entry_+# name: TestSessionRecordingsListFromQuery_1.test_recording_property_in_properties_is_routed_to_having_predicates'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13098,15 +21555,9 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), in(s.session_id,- (SELECT console_logs_log_entries.log_source_id AS log_source_id- FROM- (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, toTimeZone(log_entries.timestamp, 'UTC') AS timestamp- FROM log_entries- WHERE and(equals(log_entries.team_id, 99999), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries- WHERE and(or(equals(console_logs_log_entries.level, 'warn'), equals(console_logs_log_entries.message, 'random')), greaterOrEquals(console_logs_log_entries.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC'))))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -13123,7 +21574,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters+# name: TestSessionRecordingsListFromQuery_1.test_sessions_with_current_data'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13147,23 +21598,7 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13182,7 +21617,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_host_property_test_account_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13206,23 +21641,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13241,7 +21667,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters.2+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_host_property_test_account_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13265,14 +21691,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_one']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_one']))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13291,7 +21722,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_mandatory_filters.3+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_host_property_test_account_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13315,14 +21746,19 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), in(s.session_id, ['session_id_two']), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')), in(nullIf(nullIf(events.`$session_id`, ''), 'null'), ['session_id_two']))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(events.properties.`$host`), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13341,7 +21777,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_person_filters+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_host_property_test_account_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13365,51 +21801,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13428,7 +21827,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_operand_or_person_filters.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13452,51 +21851,64 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, '[email protected]'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000))))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter.1+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13515,7 +21927,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_ordering+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13539,7 +21951,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13558,7 +21977,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_ordering.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13582,10 +22001,17 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))- ORDER BY mouse_activity_count DESC,+ ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,max_execution_time=60,@@ -13601,7 +22027,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_person_id_filter+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter_allowing_denormalized_props'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13625,16 +22051,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null'))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13653,7 +22077,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_person_profile_finds_anonymous_distinct_id_sessions+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter_allowing_denormalized_props.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13677,16 +22101,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), or(in(s.distinct_id, ['identified-user']), globalIn(s.session_id,- (SELECT DISTINCT nullIf(nullIf(events.`$session_id`, ''), 'null') AS `$session_id`- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), lessOrEquals(events.timestamp, toDateTime64(toDateTime64('today', 6, 'UTC'), 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')))))), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13705,7 +22127,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_recording_property_in_properties_is_routed_to_having_predicates+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter_allowing_denormalized_props[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13729,9 +22151,16 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0), greater(duration, 60.0))+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,s.session_id DESCLIMIT 51 SETTINGS readonly=2,@@ -13748,7 +22177,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_sessions_with_current_data+# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter_allowing_denormalized_props[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13772,7 +22201,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13791,7 +22227,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_host_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_event_property_test_account_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13841,7 +22277,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_host_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_event_property_test_account_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13868,16 +22304,11 @@WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,(SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_idFROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)), globalNotIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(match(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '^(localhost|127\\.0\\.0\\.1)($|:)'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- LIMIT 1000000)))+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -13896,7 +22327,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_event_property_test_account_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13921,10 +22352,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(if(notEquals(toJSONString(events.properties.^is_internal_user), '{}'), toJSONString(events.properties.^is_internal_user), if(isNull(events.properties.is_internal_user), NULL, if(startsWith(dynamicType(events.properties.is_internal_user), 'DateTime'), replaceOne(toString(events.properties.is_internal_user), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.is_internal_user), 'Array'), startsWith(dynamicType(events.properties.is_internal_user), 'Map'), startsWith(dynamicType(events.properties.is_internal_user), 'Tuple')), toJSONString(events.properties.is_internal_user), toString(events.properties.is_internal_user))))), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -13946,7 +22377,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_event_property_test_account_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -13971,10 +22402,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -13996,7 +22427,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter_allowing_denormalized_props+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_person_property_test_account_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14046,7 +22477,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_event_property_test_account_filter_allowing_denormalized_props.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_person_property_test_account_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14070,14 +22501,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -14096,7 +22542,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_event_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_person_property_test_account_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14120,14 +22566,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -14146,7 +22607,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_event_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_person_property_test_account_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14171,10 +22632,10 @@coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS sWHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'is_internal_user'), ''), 'null'), '^"|"$', ''), 'true'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`HAVING 1ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESCLIMIT 1000000)))@@ -14196,7 +22657,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_person_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_top_level_person_property_test_account_filter'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14246,7 +22707,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_hogql_person_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_person_property_test_account_filter.1'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14311,7 +22772,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_person_property_test_account_filter+# name: TestSessionRecordingsListFromQuery_1.test_top_level_person_property_test_account_filter[new_events_schema.1]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14335,14 +22796,29 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,@@ -14361,7 +22837,7 @@use_hive_partitioning=0'''# ----# name: TestSessionRecordingsListFromQuery_1.test_top_level_person_property_test_account_filter.1+# name: TestSessionRecordingsListFromQuery_1.test_top_level_person_property_test_account_filter[new_events_schema]'''SELECT s.session_id AS session_id,any(s.team_id) AS `any(s.team_id)`,@@ -14385,29 +22861,14 @@round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,coalesce(max(s.surfacing_score), 0.36) AS surfacing_scoreFROM session_replay_events AS s- WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,- (SELECT nullIf(nullIf(events.`$session_id`, ''), 'null') AS session_id- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- LEFT JOIN- (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email- FROM person- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),- (SELECT person.id AS id, max(person.version) AS version- FROM person- WHERE equals(person.team_id, 99999)- GROUP BY person.id- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)- WHERE and(equals(events.team_id, 99999), notEmpty(nullIf(nullIf(events.`$session_id`, ''), 'null')), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___email, 'bla'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))- GROUP BY nullIf(nullIf(events.`$session_id`, ''), 'null')- HAVING 1- ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC- LIMIT 1000000)))+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-01-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))GROUP BY s.session_idHAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))ORDER BY start_time DESC,diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.ambrindex c2e192627afb..f66f786e7c25 100644--- a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.ambr+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.ambr@@ -56,6 +56,63 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListOperandsQueries.test_multiple_event_filters_and_ed[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListOperandsQueries.test_multiple_event_filters_or_ed'''SELECT s.session_id AS session_id,@@ -113,6 +170,63 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListOperandsQueries.test_multiple_event_filters_or_ed[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListOperandsQueries.test_positive_and_negative_anded'''SELECT s.session_id AS session_id,@@ -175,6 +289,68 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListOperandsQueries.test_positive_and_negative_anded[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING equals(countIf(and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(events.properties.`$pathname`, '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING equals(countIf(and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), 0)+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListOperandsQueries.test_two_negative_ORed'''SELECT s.session_id AS session_id,@@ -232,6 +408,63 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListOperandsQueries.test_two_negative_ORed[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), or(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notEquals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(events.properties.`$pathname`, '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListOperandsQueries.test_two_negative_anded'''SELECT s.session_id AS session_id,@@ -294,3 +527,65 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListOperandsQueries.test_two_negative_anded[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2020-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), or(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 0), and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notEquals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING and(equals(countIf(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 0)), 0), equals(countIf(and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), 0))+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(events.properties.`$pathname`, '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING and(equals(countIf(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(startsWith(dynamicType(events.properties.vip), 'DateTime'), replaceOne(toString(events.properties.vip), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.vip), 'Array'), startsWith(dynamicType(events.properties.vip), 'Map'), startsWith(dynamicType(events.properties.vip), 'Tuple')), toJSONString(events.properties.vip), toString(events.properties.vip))))), 'true'), 0)), 0), equals(countIf(and(ilike(events.properties.`$pathname`, '%target%'), isNotNull(events.properties.`$pathname`))), 0))+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_cohort.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_cohort.ambrindex 23537a91c237..e60d7ed3f349 100644--- a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_cohort.ambr+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_cohort.ambr@@ -511,6 +511,130 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByCohort.test_filter_with_events_and_cohorts[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-08-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-08-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-08-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-08-21 20:00:00.000000', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, 'custom_event'), greaterOrEquals(events.timestamp, toDateTime64('2021-08-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE equals(cohort_0.matched, 1)))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-08-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByCohort.test_filter_with_events_and_cohorts[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('2021-08-21 20:00:00.000000', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2021-08-21 19:55:00.000000', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2021-08-18 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('2021-08-21 20:00:00.000000', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), equals(events.event, '$pageview'), greaterOrEquals(events.timestamp, toDateTime64('2021-08-17 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE equals(cohort_0.matched, 1)))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('2021-08-21 20:00:00.000000', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByCohort.test_filter_with_static_and_dynamic_cohort_properties'''SELECT person_id@@ -1100,6 +1224,83 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByCohort.test_not_in_cohort_combined_with_other_filters[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), and(globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ LEFT JOIN+ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'plan'), ''), 'null'), '^"|"$', '') AS properties___plan+ FROM person+ WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),+ (SELECT person.id AS id, max(person.version) AS version+ FROM person+ WHERE equals(person.team_id, 99999)+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__person.properties___plan, 'premium'), 0), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)), in(s.distinct_id,+ (SELECT pdi.distinct_id AS distinct_id+ FROM+ (SELECT person_distinct_id2.distinct_id AS distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.is_deleted, person_distinct_id2.version) AS is_deleted+ FROM person_distinct_id2+ WHERE and(equals(person_distinct_id2.team_id, 99999), equals(person_distinct_id2.team_id, 99999))+ GROUP BY person_distinct_id2.distinct_id+ HAVING equals(is_deleted, 0)) AS pdi+ LEFT JOIN+ (SELECT cohortpeople.person_id AS person_id, 1 AS matched+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0))) AS cohort_0 ON equals(cohort_0.person_id, pdi.person_id)+ WHERE notEquals(ifNull(cohort_0.matched, 0), 1)))))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByCohort.test_not_in_cohort_with_anonymous_users_in_poe_mode'''@@ -1176,6 +1377,72 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByCohort.test_not_in_cohort_with_anonymous_users_in_poe_mode[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalNotIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),+ (SELECT persons.id AS id+ FROM+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'user_group'), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___user_group, person.id AS id+ FROM person+ WHERE and(equals(person.team_id, 99999), in(id,+ (SELECT where_optimization.id AS id+ FROM person AS where_optimization+ WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, 'user_group'), ''), 'null'), '^"|"$', ''), 'internal'), 0)))))+ GROUP BY person.id+ HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons+ WHERE ifNull(equals(persons.properties___user_group, 'internal'), 0)+ ORDER BY persons.id ASC SETTINGS optimize_aggregation_in_order=1, join_algorithm='auto')), greaterOrEquals(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---# name: TestSessionRecordingsListByCohort.test_not_in_cohort_with_empty_cohort'''diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.ambrindex 0e6cd312a9a0..46fb9529858b 100644--- a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.ambr+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.ambr@@ -329,3 +329,333 @@use_hive_partitioning=0'''# ---+# name: TestSessionRecordingsListByGroupProperties.test_filter_with_group_properties[new_events_schema.1]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2019-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'another'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___another, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___another, 'difference'), 0), greaterOrEquals(events.timestamp, toDateTime64('2019-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByGroupProperties.test_filter_with_group_properties[new_events_schema.2]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2019-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'difference'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___difference, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___difference, 'value'), 0), greaterOrEquals(events.timestamp, toDateTime64('2019-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByGroupProperties.test_filter_with_group_properties[new_events_schema.3]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2019-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 0))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_0 ON equals(events.`$group_0`, events__group_0.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_0.properties___industry, 'finance'), 0), greaterOrEquals(events.timestamp, toDateTime64('2019-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByGroupProperties.test_filter_with_group_properties[new_events_schema.4]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2019-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'industry'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___industry, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 0))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_0 ON equals(events.`$group_0`, events__group_0.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_0.properties___industry, 'difference'), 0), greaterOrEquals(events.timestamp, toDateTime64('2019-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByGroupProperties.test_filter_with_group_properties[new_events_schema.5]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2019-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'difference'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___difference, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 0))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_0 ON equals(events.`$group_0`, events__group_0.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_0.properties___difference, 'finance'), 0), greaterOrEquals(events.timestamp, toDateTime64('2019-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---+# name: TestSessionRecordingsListByGroupProperties.test_filter_with_group_properties[new_events_schema]+ '''+ SELECT s.session_id AS session_id,+ any(s.team_id) AS `any(s.team_id)`,+ any(s.distinct_id) AS `any(s.distinct_id)`,+ min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,+ max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,+ dateDiff('SECOND', start_time, end_time) AS duration,+ argMinMerge(s.first_url) AS first_url,+ sum(s.click_count) AS click_count,+ sum(s.keypress_count) AS keypress_count,+ sum(s.mouse_activity_count) AS mouse_activity_count,+ divide(sum(s.active_milliseconds), 1000) AS active_seconds,+ minus(duration, active_seconds) AS inactive_seconds,+ sum(s.console_log_count) AS console_log_count,+ sum(s.console_warn_count) AS console_warn_count,+ sum(s.console_error_count) AS console_error_count,+ max(s.retention_period_days) AS retention_period_days,+ plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,+ dateDiff('DAY', toDateTime64('today', 6, 'UTC'), expiry_time) AS recording_ttl,+ greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('today', 6, 'UTC')) AS ongoing,+ round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score,+ coalesce(max(s.surfacing_score), 0.36) AS surfacing_score+ FROM session_replay_events AS s+ WHERE and(equals(s.team_id, 99999), greaterOrEquals(s.min_first_timestamp, toDateTime64('2019-12-29 00:00:00.000000', 6, 'UTC')), lessOrEquals(s.min_first_timestamp, toDateTime64('today', 6, 'UTC')), globalIn(s.session_id,+ (SELECT events.properties.`$session_id` AS session_id+ FROM events_json AS events+ LEFT JOIN+ (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(groups.group_properties, 'another'), ''), 'null'), '^"|"$', '')), toTimeZone(groups._timestamp, 'UTC')), 1) AS properties___another, groups.group_type_index AS index, groups.group_key AS key+ FROM groups+ WHERE and(equals(groups.team_id, 99999), equals(index, 1))+ GROUP BY groups.group_type_index, groups.group_key) AS events__group_1 ON equals(events.`$group_1`, events__group_1.key)+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), lessOrEquals(events.timestamp, now64(6, 'UTC')), ifNull(equals(events__group_1.properties___another, 'value'), 0), greaterOrEquals(events.timestamp, toDateTime64('2019-12-28 00:00:00.000000', 6, 'UTC')))+ GROUP BY events.properties.`$session_id`+ HAVING 1+ ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC+ LIMIT 1000000)))+ GROUP BY s.session_id+ HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))+ ORDER BY start_time DESC,+ s.session_id DESC+ LIMIT 51 SETTINGS readonly=2,+ max_execution_time=60,+ allow_experimental_object_type=1,+ max_ast_elements=4000000,+ max_expanded_ast_elements=4000000,+ max_bytes_before_external_group_by=0,+ transform_null_in=1,+ optimize_min_equality_disjunction_chain_length=4294967295,+ optimize_rewrite_aggregate_function_with_if=0,+ optimize_min_inequality_conjunction_chain_length=4294967295,+ allow_experimental_join_condition=1,+ use_hive_partitioning=0+ '''+# ---diff --git a/posthog/tasks/test/__snapshots__/test_usage_report.ambr b/posthog/tasks/test/__snapshots__/test_usage_report.ambrindex c2637666a9d1..10ddec6c16a3 100644--- a/posthog/tasks/test/__snapshots__/test_usage_report.ambr+++ b/posthog/tasks/test/__snapshots__/test_usage_report.ambr@@ -2010,7 +2010,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 00:00:00'AND timestamp < '2022-01-10 02:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2022,7 +2022,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 02:00:00'AND timestamp < '2022-01-10 04:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2034,7 +2034,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 04:00:00'AND timestamp < '2022-01-10 06:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2046,7 +2046,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 06:00:00'AND timestamp < '2022-01-10 08:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2058,7 +2058,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 08:00:00'AND timestamp < '2022-01-10 10:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2105,7 +2105,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 10:00:00'AND timestamp < '2022-01-10 12:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2117,7 +2117,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 12:00:00'AND timestamp < '2022-01-10 14:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2129,7 +2129,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 14:00:00'AND timestamp < '2022-01-10 16:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2141,7 +2141,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 16:00:00'AND timestamp < '2022-01-10 18:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2153,7 +2153,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 18:00:00'AND timestamp < '2022-01-10 20:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2165,7 +2165,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 20:00:00'AND timestamp < '2022-01-10 22:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2177,7 +2177,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 22:00:00'AND timestamp < '2022-01-10 23:59:59'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']GROUP BY team_id'''# ---@@ -2189,7 +2189,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 00:00:00'AND timestamp < '2022-01-10 02:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2203,7 +2203,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 02:00:00'AND timestamp < '2022-01-10 04:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2217,7 +2217,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 04:00:00'AND timestamp < '2022-01-10 06:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2266,7 +2266,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 06:00:00'AND timestamp < '2022-01-10 08:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2280,7 +2280,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 08:00:00'AND timestamp < '2022-01-10 10:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2294,7 +2294,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 10:00:00'AND timestamp < '2022-01-10 12:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2308,7 +2308,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 12:00:00'AND timestamp < '2022-01-10 14:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2322,7 +2322,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 14:00:00'AND timestamp < '2022-01-10 16:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2336,7 +2336,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 16:00:00'AND timestamp < '2022-01-10 18:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2350,7 +2350,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 18:00:00'AND timestamp < '2022-01-10 20:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2364,7 +2364,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 20:00:00'AND timestamp < '2022-01-10 22:00:00'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2378,7 +2378,7 @@FROM events_jsonWHERE timestamp >= '2022-01-10 22:00:00'AND timestamp < '2022-01-10 23:59:59'- AND event NOT IN ['$feature_flag_called', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']+ AND event NOT IN ['$feature_flag_called', '$experiment_exposure', 'survey sent', 'survey shown', 'survey dismissed', '$exception', '$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters', '$conversations_loaded', '$conversations_widget_loaded', '$conversations_message_sent', '$conversations_user_identified', '$conversations_restore_link_requested', '$conversations_widget_state_changed', '$conversations_back_to_tickets']AND person_mode IN ('full','force_upgrade')GROUP BY team_id@@ -2504,16 +2504,22 @@SELECT team_id,COUNT() - uniqExactIf(request_id, verified- AND request_id != '') as count+ AND NOT relay+ AND request_id != '') AS count,+ max(relay) AS has_verified_relayFROM(SELECT team_id,replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_gateway_verified`) != '{}', toJSONString(properties.^`$ai_gateway_verified`), if(startsWith(dynamicType(properties.`$ai_gateway_verified`), 'Array')OR startsWith(dynamicType(properties.`$ai_gateway_verified`), 'Map')OR startsWith(dynamicType(properties.`$ai_gateway_verified`), 'Tuple'), toJSONString(properties.`$ai_gateway_verified`), if(startsWith(dynamicType(properties.`$ai_gateway_verified`), 'DateTime'), replaceOne(toString(properties.`$ai_gateway_verified`), ' ', 'T'), toString(properties.`$ai_gateway_verified`)))), ''), '^"|"$', '') IN ('true',- '1') as verified,+ '1') AS verified,if(verified, replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_gateway_request_id`) != '{}', toJSONString(properties.^`$ai_gateway_request_id`), if(startsWith(dynamicType(properties.`$ai_gateway_request_id`), 'Array')OR startsWith(dynamicType(properties.`$ai_gateway_request_id`), 'Map')- OR startsWith(dynamicType(properties.`$ai_gateway_request_id`), 'Tuple'), toJSONString(properties.`$ai_gateway_request_id`), if(startsWith(dynamicType(properties.`$ai_gateway_request_id`), 'DateTime'), replaceOne(toString(properties.`$ai_gateway_request_id`), ' ', 'T'), toString(properties.`$ai_gateway_request_id`)))), ''), '^"|"$', ''), '') as request_id+ OR startsWith(dynamicType(properties.`$ai_gateway_request_id`), 'Tuple'), toJSONString(properties.`$ai_gateway_request_id`), if(startsWith(dynamicType(properties.`$ai_gateway_request_id`), 'DateTime'), replaceOne(toString(properties.`$ai_gateway_request_id`), ' ', 'T'), toString(properties.`$ai_gateway_request_id`)))), ''), '^"|"$', ''), '') AS request_id,+ if(verified, replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_gateway_relay`) != '{}', toJSONString(properties.^`$ai_gateway_relay`), if(startsWith(dynamicType(properties.`$ai_gateway_relay`), 'Array')+ OR startsWith(dynamicType(properties.`$ai_gateway_relay`), 'Map')+ OR startsWith(dynamicType(properties.`$ai_gateway_relay`), 'Tuple'), toJSONString(properties.`$ai_gateway_relay`), if(startsWith(dynamicType(properties.`$ai_gateway_relay`), 'DateTime'), replaceOne(toString(properties.`$ai_gateway_relay`), ' ', 'T'), toString(properties.`$ai_gateway_relay`)))), ''), '^"|"$', ''), '') IN ('true',+ '1') AS relayFROM events_jsonWHERE event IN ['$ai_generation', '$ai_embedding', '$ai_span', '$ai_trace', '$ai_metric', '$ai_feedback', '$ai_evaluation', '$ai_tag', '$ai_trace_summary', '$ai_generation_summary', '$ai_trace_clusters', '$ai_generation_clusters']AND timestamp >= '2022-01-10 00:00:00'diff --git a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambrindex 760424b9334a..6af6f4835744 100644--- a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr+++ b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr@@ -2351,35 +2351,35 @@(SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_count- FROM- (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_id+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_idFROM- (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)- and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timings+ (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_countFROM- (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_idFROM- (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)+ and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timingsFROM- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))- ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)- GROUP BY person_id) ARRAY- JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY- JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))- WHERE equals(path_key, '2_/2')- GROUP BY person_id) AS source)))+ (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ FROM+ (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ FROM+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))+ ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)+ GROUP BY person_id) ARRAY+ JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY+ JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))+ WHERE equals(path_key, '2_/2')+ GROUP BY person_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.id ASC@@ -2533,35 +2533,35 @@(SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_count- FROM- (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_id+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_idFROM- (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)- and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timings+ (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_countFROM- (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_idFROM- (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)+ and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timingsFROM- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))- ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)- GROUP BY person_id) ARRAY- JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY- JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))- WHERE and(equals(path_dropoff_key, '2_/2'), equals(path_dropoff_key, path_key))- GROUP BY person_id) AS source)))+ (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ FROM+ (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ FROM+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))+ ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)+ GROUP BY person_id) ARRAY+ JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY+ JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))+ WHERE and(equals(path_dropoff_key, '2_/2'), equals(path_dropoff_key, path_key))+ GROUP BY person_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.id ASC@@ -2691,35 +2691,35 @@(SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_count- FROM- (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_id+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_idFROM- (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)- and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timings+ (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_countFROM- (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_idFROM- (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)+ and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timingsFROM- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))- ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)- GROUP BY person_id) ARRAY- JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY- JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))- WHERE and(equals(path_dropoff_key, '3_/3'), equals(path_dropoff_key, path_key))- GROUP BY person_id) AS source)))+ (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ FROM+ (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ FROM+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))+ ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)+ GROUP BY person_id) ARRAY+ JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY+ JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))+ WHERE and(equals(path_dropoff_key, '3_/3'), equals(path_dropoff_key, path_key))+ GROUP BY person_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.id ASC@@ -2873,35 +2873,35 @@(SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at,person.id AS idFROM person- WHERE and(equals(person.team_id, 99999), in(id,- (SELECT source.actor_id AS actor_id- FROM- (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_count- FROM- (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_id+ WHERE and(equals(person.team_id, 99999), globalIn(id,+ (SELECT source.actor_id AS actor_idFROM- (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)- and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timings+ (SELECT person_id AS actor_id, groupUniqArray(100)(tuple(timestamp, uuid, session_id, window_id)) AS matching_events, count(*) AS event_countFROM- (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ (SELECT person_id AS person_id, path AS path, conversion_time AS conversion_time, event_in_session_index AS event_in_session_index, concat(ifNull(toString(event_in_session_index), ''), '_', ifNull(toString(path), '')) AS path_key, if(ifNull(greater(event_in_session_index, 1), 0), concat(ifNull(toString(minus(event_in_session_index, 1)), ''), '_', ifNull(toString(prev_path), '')), NULL) AS last_path_key, path_dropoff_key AS path_dropoff_key, final_uuid AS uuid, final_timestamp AS timestamp, final_session_id AS session_id, final_window_id AS window_idFROM- (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ (SELECT person_id AS person_id, joined_path_tuple.1 AS path, joined_path_tuple.2 AS conversion_time, joined_path_tuple.3 AS prev_path, event_in_session_index, session_index AS session_index, arrayPopFront(arrayPushBack(path_basic, '')) AS path_basic_0, arrayMap((x, y) -> if(ifNull(equals(x, y), isNull(x)+ and isNull(y)), 0, 1), path_basic, path_basic_0) AS mapping, arrayFilter((x, y) -> y, time, mapping) AS timings, arrayFilter((x, y) -> y, path_basic, mapping) AS compact_path, indexOf(compact_path, NULL) AS target_index, joined_path_tuple.4 AS final_uuid, joined_path_tuple.5 AS final_timestamp, joined_path_tuple.6 AS final_session_id, joined_path_tuple.7 AS final_window_id, arrayFilter((x, y) -> y, uuid_items, mapping) AS uuid, arrayFilter((x, y) -> y, timestamp_items, mapping) AS timestamp, arrayFilter((x, y) -> y, session_id_items, mapping) AS session_id, arrayFilter((x, y) -> y, window_id_items, mapping) AS window_id, if(ifNull(greater(target_index, 0), 0), arraySlice(compact_path, target_index), compact_path) AS filtered_path, arraySlice(filtered_path, 1, 5) AS limited_path, if(ifNull(greater(target_index, 0), 0), arraySlice(timings, target_index), timings) AS filtered_timings, arraySlice(filtered_timings, 1, 5) AS limited_timings, if(ifNull(greater(target_index, 0), 0), arraySlice(uuid, target_index), uuid) AS filtered_uuid, arraySlice(filtered_uuid, 1, 5) AS limited_uuid, if(ifNull(greater(target_index, 0), 0), arraySlice(timestamp, target_index), timestamp) AS filtered_timestamp, arraySlice(filtered_timestamp, 1, 5) AS limited_timestamp, if(ifNull(greater(target_index, 0), 0), arraySlice(session_id, target_index), session_id) AS filtered_session_id, arraySlice(filtered_session_id, 1, 5) AS limited_session_id, if(ifNull(greater(target_index, 0), 0), arraySlice(window_id, target_index), window_id) AS filtered_window_id, arraySlice(filtered_window_id, 1, 5) AS limited_window_id, arrayDifference(limited_timings) AS timings_diff, concat(ifNull(toString(length(limited_path)), ''), '_', ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, '')), limited_uuid, limited_timestamp, limited_session_id, limited_window_id) AS limited_path_timingsFROM- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item- FROM events- LEFT OUTER JOIN- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id, 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))- ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)- GROUP BY person_id) ARRAY- JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY- JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))- WHERE equals(path_key, '2_/2')- GROUP BY person_id) AS source)))+ (SELECT person_id AS person_id, path_time_tuple.1 AS path_basic, path_time_tuple.2 AS time, session_index, arrayZip(path_list, timing_list, arrayDifference(timing_list), uuid_list, timestamp_list, session_id_list, window_id_list) AS paths_tuple, arraySplit(x -> if(less(x.3, 1800), 0, 1), paths_tuple) AS session_paths, path_time_tuple.4 AS uuid_items, path_time_tuple.5 AS timestamp_items, path_time_tuple.6 AS session_id_items, path_time_tuple.7 AS window_id_items+ FROM+ (SELECT person_id AS person_id, groupArray(timestamp) AS timing_list, groupArray(path_item) AS path_list, groupArray(uuid) AS uuid_list, groupArray(timestamp) AS timestamp_list, groupArray(session_id) AS session_id_list, groupArray(window_id) AS window_id_list+ FROM+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped, events.uuid AS uuid, toTimeZone(events.timestamp, 'UTC') AS timestamp, ifNull(nullIf(nullIf(events.`$session_id`, ''), 'null'), '') AS session_id, ifNull(nullIf(nullIf(events.`$window_id`, ''), 'null'), '') AS window_id, NULL AS groupings, multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index, (if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item+ FROM events+ LEFT OUTER JOIN+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id+ FROM person_distinct_id_overrides+ WHERE equals(person_distinct_id_overrides.team_id, 99999)+ GROUP BY person_distinct_id_overrides.distinct_id+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2012-01-02 23:59:59', 'UTC')))), equals(events.event, '$pageview'))+ ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)+ GROUP BY person_id) ARRAY+ JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index) ARRAY+ JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index))+ WHERE equals(path_key, '2_/2')+ GROUP BY person_id) AS source)))GROUP BY person.idHAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id)ORDER BY persons.id ASC@@ -3212,7 +3212,7 @@person.id AS idFROM personWHERE and(equals(person.team_id,- 99999), in(id, (+ 99999), globalIn(id, (SELECT source.actor_id AS actor_idFROM (SELECT person_id AS actor_id,diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.ambrindex 2dd569fdfb94..99fda3e38a7e 100644--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.ambr+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.ambr@@ -897,14 +897,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(isNotNull(events.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0)))))+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0)))))GROUP BY session_idHAVING or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0))LIMIT 100 SETTINGS readonly=2,diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambrindex 7580052439a4..cdecea45c49e 100644--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr@@ -2789,14 +2789,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`HAVING and(isNotNull(`context.columns.breakdown_value`), ifNull(notEquals(`context.columns.breakdown_value`, ''), 1))@@ -2927,14 +2927,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(nullIf(tupleElement(first_pageview_properties, 1), ''), 'google'), 0))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(nullIf(tupleElement(first_pageview_properties, 1), ''), 'google'), 0))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESC,@@ -3063,14 +3063,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(nullIf(tupleElement(first_pageview_properties, 1), ''), 'google.com'), 0))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(nullIf(tupleElement(first_pageview_properties, 1), ''), 'google.com'), 0))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESC,@@ -3197,14 +3197,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))GROUP BY session_id,breakdown_value)GROUP BY breakdown_value) AS counts@@ -3227,14 +3227,14 @@FROM raw_sessionsWHERE and(equals(raw_sessions.team_id, 99999), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC')), toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')), toIntervalDay(3))))GROUP BY raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7)- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))GROUP BY session_id,breakdown_value)GROUP BY breakdown_value) AS bounce ON equals(counts.breakdown_value, bounce.breakdown_value)@@ -3394,14 +3394,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))GROUP BY session_id,breakdown_value)GROUP BY breakdown_value) AS counts@@ -3412,14 +3412,14 @@quantileIf(0.9)(least(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$prev_pageview_duration'), ''), 'null'), '^"|"$', ''), 'Float64'), 86400),0) AS previous_avg_time_on_pageFROM events- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$prev_pageview_pathname'), ''), 'null'), '^"|"$', '')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$prev_pageview_duration'), ''), 'null'), '^"|"$', '')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$prev_pageview_pathname'), ''), 'null'), '^"|"$', '')), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$prev_pageview_duration'), ''), 'null'), '^"|"$', '')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)LEFT JOIN(SELECT breakdown_value AS breakdown_value,@@ -3440,14 +3440,14 @@FROM raw_sessionsWHERE and(equals(raw_sessions.team_id, 99999), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC')), toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')), toIntervalDay(3))))GROUP BY raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7)- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_campaign'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_source'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$referring_domain'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'fbclid'), ''), 'null'), '^"|"$', ''), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'gad_source'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'paid'), isNotNull(nullIf(tupleElement(first_pageview_properties, 6), '')), isNotNull(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 8), ''), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Paid Video', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null'))), or(isNull(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null'))), in(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 3), ''), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(nullIf(tupleElement(first_pageview_properties, 5), ''), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 1), ''), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(nullIf(tupleElement(first_pageview_properties, 2), ''), ''), 'null')), 'push$'), 'Push', isNotNull(nullIf(tupleElement(first_pageview_properties, 7), '')), 'Organic Social', ifNull(equals(nullIf(tupleElement(first_pageview_properties, 5), ''), '$direct'), 0), 'Direct', isNotNull(nullIf(tupleElement(first_pageview_properties, 5), '')), 'Referral', 'Unknown'))), 'Paid Search'), 0))), 1))GROUP BY session_id,breakdown_value)GROUP BY breakdown_value) AS bounce ON equals(counts.breakdown_value, bounce.breakdown_value)@@ -3624,14 +3624,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE in(nullIf(tupleElement(first_pageview_properties, 1), ''), tuple('paid', 'cpc', 'ppc', 'paidsearch', 'paidSocial', 'paid_social')))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE in(nullIf(tupleElement(first_pageview_properties, 1), ''), tuple('paid', 'cpc', 'ppc', 'paidsearch', 'paidSocial', 'paid_social')))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESC,@@ -3708,14 +3708,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE in(nullIf(tupleElement(first_pageview_properties, 1), ''), tuple('cpc', 'email')))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE in(nullIf(tupleElement(first_pageview_properties, 1), ''), tuple('cpc', 'email')))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESC,@@ -3792,14 +3792,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(equals(nullIf(tupleElement(first_pageview_properties, 1), ''), 'cpc'), 0))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(equals(nullIf(tupleElement(first_pageview_properties, 1), ''), 'cpc'), 0))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESC,@@ -3953,14 +3953,14 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), in(events.`$session_id`,- (SELECT session_id AS session_id- FROM- (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties- FROM events- WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))- GROUP BY session_id)- WHERE ifNull(notIn(nullIf(tupleElement(first_pageview_properties, 1), ''), tuple('cpc', 'paid')), 1))), isNotNull(events.`$session_id_uuid`)))+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.`$session_id`,+ (SELECT session_id AS session_id+ FROM+ (SELECT events.`$session_id` AS session_id, argMinIf(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'utm_medium'), ''), 'null'), '^"|"$', '')), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties+ FROM events+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(events.`$session_id_uuid`)))+ GROUP BY session_id)+ WHERE ifNull(notIn(nullIf(tupleElement(first_pageview_properties, 1), ''), tuple('cpc', 'paid')), 1))), isNotNull(events.`$session_id_uuid`)))GROUP BY session_id))GROUP BY `context.columns.breakdown_value`ORDER BY `context.columns.visitors` DESC,diff --git a/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.ambr b/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.ambrindex 69e6521d39e5..61bdc0a1102a 100644--- a/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.ambr+++ b/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.ambr@@ -130,10 +130,10 @@round(divide(heatmaps.x, heatmaps.viewport_width), 2) AS pointer_relative_x,multiply(heatmaps.y, heatmaps.scale_factor) AS client_yFROM heatmaps- WHERE and(equals(heatmaps.team_id, 99999), equals(heatmaps.type, 'click'), ifNull(greaterOrEquals(heatmaps.timestamp, toDateTime64(toDate('2023-03-08'), 6, 'UTC')), 0), lessOrEquals(heatmaps.timestamp, plus('2025-03-31', toIntervalDay(1))), not(and(equals(heatmaps.x, 0), equals(heatmaps.y, 0))), in(heatmaps.session_id,- (SELECT DISTINCT events.`$session_id` AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(events.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '%127.0.0.1%'), 1)))))))+ WHERE and(equals(heatmaps.team_id, 99999), equals(heatmaps.type, 'click'), ifNull(greaterOrEquals(heatmaps.timestamp, toDateTime64(toDate('2023-03-08'), 6, 'UTC')), 0), lessOrEquals(heatmaps.timestamp, plus('2025-03-31', toIntervalDay(1))), not(and(equals(heatmaps.x, 0), equals(heatmaps.y, 0))), globalIn(heatmaps.session_id,+ (SELECT DISTINCT events.`$session_id` AS `$session_id`+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '%127.0.0.1%'), 1)))))))GROUP BY pointer_target_fixed,pointer_relative_x,client_y@@ -160,10 +160,10 @@countIf(and(greater(heatmaps.y, heatmaps.viewport_height), not(heatmaps.pointer_target_fixed))) AS below_fold,round(quantile(0.5)(multiply(heatmaps.viewport_height, heatmaps.scale_factor))) AS median_viewport_heightFROM heatmaps- WHERE and(equals(heatmaps.team_id, 99999), equals(heatmaps.type, 'click'), ifNull(greaterOrEquals(heatmaps.timestamp, toDateTime64(toDate('2023-03-08'), 6, 'UTC')), 0), lessOrEquals(heatmaps.timestamp, plus('2025-03-31', toIntervalDay(1))), not(and(equals(heatmaps.x, 0), equals(heatmaps.y, 0))), in(heatmaps.session_id,- (SELECT DISTINCT events.`$session_id` AS `$session_id`- FROM events- WHERE and(equals(events.team_id, 99999), notEmpty(events.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '%127.0.0.1%'), 1))))))+ WHERE and(equals(heatmaps.team_id, 99999), equals(heatmaps.type, 'click'), ifNull(greaterOrEquals(heatmaps.timestamp, toDateTime64(toDate('2023-03-08'), 6, 'UTC')), 0), lessOrEquals(heatmaps.timestamp, plus('2025-03-31', toIntervalDay(1))), not(and(equals(heatmaps.x, 0), equals(heatmaps.y, 0))), globalIn(heatmaps.session_id,+ (SELECT DISTINCT events.`$session_id` AS `$session_id`+ FROM events+ WHERE and(equals(events.team_id, 99999), notEmpty(events.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$host'), ''), 'null'), '^"|"$', '')), '%127.0.0.1%'), 1))))))LIMIT 1000000 SETTINGS readonly=2,max_execution_time=60,allow_experimental_object_type=1,