Skip to content

: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.

fix(ci): stop the snapshot bot deleting new-events-schema snapshots (#86200)

Julian Bez49a31b629249
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index fde79144d845..e2546df2d0c3 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -72,7 +72,9 @@
# for the gha-workflow-env-secret Semgrep fix) is depot-exempt. Login is best-effort
# because these jobs only pull public images and can fall back to anonymous pulls.
# - Path-filter persons-SQL is folded into migrations
-# - Snapshot mode matches canonical, but snapshot patch upload/commit is stripped
+# - Snapshot mode matches canonical, but snapshot patch upload/commit is stripped;
+# canonical's per-schema-leg patch scoping (legacy legs exclude *.new_events_schema.ambr,
+# events_json legs ship only those) is therefore depot-exempt too
# - Test durations restored from Depot Cache (posthog-test-durations- prefix), refreshed by
# .depot/workflows/ci-backend-update-test-timing.yml, so shard counts match GitHub Actions.
# Committed .test_durations is the fallback.
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 14613318412e..6d13cf3861ed 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -1231,11 +1231,20 @@ jobs:
- name: Generate snapshot patch
if: ${{ always() && needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' }}
shell: bash
+ env:
+ NEW_EVENTS_SCHEMA: ${{ matrix.new-events-schema && 'true' || 'false' }}
run: |
mkdir -p /tmp/patches
git add -N '*.ambr' || true
- if ! git diff --quiet '*.ambr' 2>/dev/null; then
- git diff --binary --full-index '*.ambr' > /tmp/patches/backend-Products-${{ strategy.job-index }}.patch
+ # Same leg scoping as the django job: a leg may only ship its own
+ # schema mode's snapshot files (see the comment there).
+ if [[ "$NEW_EVENTS_SCHEMA" == "true" ]]; then
+ ambr_pathspec=('*.new_events_schema.ambr')
+ else
+ ambr_pathspec=('*.ambr' ':(exclude)*.new_events_schema.ambr')
+ fi
+ if ! git diff --quiet -- "${ambr_pathspec[@]}" 2>/dev/null; then
+ git diff --binary --full-index -- "${ambr_pathspec[@]}" > /tmp/patches/backend-Products-${{ strategy.job-index }}.patch
echo "Generated patch with $(wc -l < /tmp/patches/backend-Products-${{ strategy.job-index }}.patch) lines"
else
echo "No snapshot changes to patch"
@@ -2698,9 +2707,9 @@ jobs:
fi
if [[ "$RUN_NEW_EVENTS_SCHEMA" != "true" ]]; then
- # Unlabeled PRs skip the doubled schema matrix; note their snapshot
- # bot commits then leave [new_events_schema] .ambr blocks untouched,
- # so those blocks only refresh on labeled PRs and stay stale between.
+ # Unlabeled PRs skip the doubled schema matrix; their snapshot
+ # bot commits leave *.new_events_schema.ambr files untouched, so
+ # those only refresh on labeled PRs / dispatch and stay stale between.
echo "Skipping new-events-schema variants (add the test-new-events-schema label to run them)"
core_new_events_schema="[]"
core_persons_on_events_new_schema="[]"
@@ -3091,9 +3100,10 @@ jobs:
if: ${{ needs.changes.outputs.backend == 'true' && (needs.detect-snapshot-mode.outputs.mode == 'update' || matrix.person-on-events) }}
shell: bash
# --snapshot-warn-unused: pytest-split shards individual tests across
- # runners, so each shard only exercises a subset of snapshots per file.
- # Without this flag, --snapshot-update deletes "unused" snapshots that
- # belong to other shards, causing cross-shard data loss.
+ # runners, so a shard reports other shards' snapshots as "unused". The flag
+ # downgrades that from a failure to a warning. It does NOT prevent deletion:
+ # --snapshot-update only spares a snapshot when syrupy matches it to a test
+ # (by file and name) that did not run on this shard.
run: echo "PYTEST_ARGS=--snapshot-update --snapshot-warn-unused" >> $GITHUB_ENV
- name: Add snapshot flags for compat subset runs
@@ -3415,13 +3425,24 @@ jobs:
# Only in UPDATE mode - CHECK mode verifies snapshots match exactly
if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure' }}
shell: bash
+ env:
+ NEW_EVENTS_SCHEMA: ${{ matrix.new-events-schema && 'true' || 'false' }}
run: |
mkdir -p /tmp/patches
# Stage any new/modified .ambr files so they appear in git diff
git add -N '*.ambr' || true
+ # Each schema leg may only ship its own snapshot files. A leg still
+ # *claims* the other schema mode's snapshot names without writing them,
+ # so syrupy deletes them from the working tree as unused; scoping the
+ # patch keeps those deletions out of the committed diff.
+ if [[ "$NEW_EVENTS_SCHEMA" == "true" ]]; then
+ ambr_pathspec=('*.new_events_schema.ambr')
+ else
+ ambr_pathspec=('*.ambr' ':(exclude)*.new_events_schema.ambr')
+ fi
# Generate patch if there are changes
- if ! git diff --quiet '*.ambr' 2>/dev/null; then
- git diff --binary --full-index '*.ambr' > /tmp/patches/backend-${{ matrix.artifact_key }}.patch
+ if ! git diff --quiet -- "${ambr_pathspec[@]}" 2>/dev/null; then
+ git diff --binary --full-index -- "${ambr_pathspec[@]}" > /tmp/patches/backend-${{ matrix.artifact_key }}.patch
echo "Generated patch with $(wc -l < /tmp/patches/backend-${{ matrix.artifact_key }}.patch) lines"
else
echo "No snapshot changes to patch"
diff --git a/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr b/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr
new file mode 100644
index 000000000000..ab321100cbda
--- /dev/null
+++ b/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr
@@ -0,0 +1,208 @@
+# serializer version: 1
+# name: TestEvents.test_event_property_values[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%qw%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema.2]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%QW%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema.3]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%6%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema.4]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), equals(events.event, 'random event'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%6%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema.5]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), or(equals(events.event, 'foo'), equals(events.event, 'random event')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%6%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema.6]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), equals(events.event, '404_i_dont_exist'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%qw%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema.7]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), equals(events.event, '404_i_dont_exist'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))), '%qw%'), 0))
+ ORDER BY length(toString(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))) ASC
+ LIMIT 10 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: TestEvents.test_event_property_values[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.random_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.random_prop)))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, if(startsWith(dynamicType(properties.random_prop), 'DateTime'), concat('"', replaceOne(toString(properties.random_prop), ' ', 'T'), '"'), toJSONString(properties.random_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, if(startsWith(dynamicType(events.properties.random_prop), 'DateTime'), replaceOne(toString(events.properties.random_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.random_prop), 'Array'), startsWith(dynamicType(events.properties.random_prop), 'Map'), startsWith(dynamicType(events.properties.random_prop), 'Tuple')), toJSONString(events.properties.random_prop), toString(events.properties.random_prop)))))))
+ LIMIT 10 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: TestEvents.test_event_property_values_with_hidden_properties[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^visible_prop), '{}'), toJSONString(events.properties.^visible_prop), if(isNull(events.properties.visible_prop), NULL, if(startsWith(dynamicType(events.properties.visible_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.visible_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.visible_prop)))) AS `if(notEquals(toJSONString(properties.^visible_prop), '{}'), toJSONString(properties.^visible_prop), if(isNull(properties.visible_prop), NULL, if(startsWith(dynamicType(properties.visible_prop), 'DateTime'), concat('"', replaceOne(toString(properties.visible_prop), ' ', 'T'), '"'), toJSONString(properties.visible_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^visible_prop), '{}'), toJSONString(events.properties.^visible_prop), if(isNull(events.properties.visible_prop), NULL, if(startsWith(dynamicType(events.properties.visible_prop), 'DateTime'), replaceOne(toString(events.properties.visible_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.visible_prop), 'Array'), startsWith(dynamicType(events.properties.visible_prop), 'Map'), startsWith(dynamicType(events.properties.visible_prop), 'Tuple')), toJSONString(events.properties.visible_prop), toString(events.properties.visible_prop)))))))
+ LIMIT 10 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: TestEvents.test_event_property_values_without_hidden_properties[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), concat('"', ifNull(toString(replaceOne(toString(events.properties.test_prop), ' ', 'T')), ''), '"'), toJSONString(events.properties.test_prop)))) AS `if(notEquals(toJSONString(properties.^test_prop), '{}'), toJSONString(properties.^test_prop), if(isNull(properties.test_prop), NULL, if(startsWith(dynamicType(properties.test_prop), 'DateTime'), concat('"', replaceOne(toString(properties.test_prop), ' ', 'T'), '"'), toJSONString(properties.test_prop))))`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2020-01-13 00:00:00', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-20 23:59:59', 6, 'UTC')), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))))))
+ LIMIT 10 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/api/test/__snapshots__/test_persons_trends.ambr b/posthog/api/test/__snapshots__/test_persons_trends.ambr
index 80a861389dcf..588c2e60e624 100644
--- a/posthog/api/test/__snapshots__/test_persons_trends.ambr
+++ b/posthog/api/test/__snapshots__/test_persons_trends.ambr
@@ -108,115 +108,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonTrends.test_trends_people_endpoint_filters_search[new_events_schema.1]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT source.actor_id AS actor_id,
- source.event_count AS event_count,
- source.matching_events AS matching_events,
- source.event_distinct_ids AS event_distinct_ids
- 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,
- 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.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- e.distinct_id AS distinct_id
- 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 person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name
- 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 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), or(ifNull(ilike(toString(e__person.properties___email), '%ben%'), 0), ifNull(ilike(toString(e__person.properties___name), '%ben%'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(e.properties.^distinct_id), '{}'), toJSONString(e.properties.^distinct_id), if(isNull(e.properties.distinct_id), NULL, if(startsWith(dynamicType(e.properties.distinct_id), 'DateTime'), replaceOne(toString(e.properties.distinct_id), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.distinct_id), 'Array'), startsWith(dynamicType(e.properties.distinct_id), 'Map'), startsWith(dynamicType(e.properties.distinct_id), 'Tuple')), toJSONString(e.properties.distinct_id), toString(e.properties.distinct_id)))))), '%ben%'), 0)), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), or(isNull(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), ifNull(equals(ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), 400), ''), '$$_posthog_breakdown_null_$$'), '$$_posthog_breakdown_null_$$'), 0)), equals(e.event, '$pageview')))
- GROUP BY actor_id) AS source
- ORDER BY source.actor_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: TestPersonTrends.test_trends_people_endpoint_filters_search[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT source.actor_id AS actor_id,
- source.event_count AS event_count,
- source.matching_events AS matching_events,
- source.event_distinct_ids AS event_distinct_ids
- 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,
- 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.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- e.distinct_id AS distinct_id
- 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), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), or(isNull(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), ifNull(equals(ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), 400), ''), '$$_posthog_breakdown_null_$$'), '$$_posthog_breakdown_null_$$'), 0)), equals(e.event, '$pageview')))
- GROUP BY actor_id) AS source
- ORDER BY source.actor_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: TestPersonTrends.test_trends_people_endpoint_includes_recordings
'''
/* user_id:0 request:_snapshot_ */
@@ -279,52 +170,3 @@
HAVING max(is_deleted) = 0
'''
# ---
-# name: TestPersonTrends.test_trends_people_endpoint_includes_recordings[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT source.actor_id AS actor_id,
- source.event_count AS event_count,
- source.matching_events AS matching_events,
- source.event_distinct_ids AS event_distinct_ids
- 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,
- 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.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- e.distinct_id AS distinct_id
- 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), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), or(isNull(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), ifNull(equals(ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), 400), ''), '$$_posthog_breakdown_null_$$'), '$$_posthog_breakdown_null_$$'), 0)), equals(e.event, '$pageview')))
- GROUP BY actor_id) AS source
- ORDER BY source.actor_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/api/test/__snapshots__/test_persons_trends.new_events_schema.ambr b/posthog/api/test/__snapshots__/test_persons_trends.new_events_schema.ambr
new file mode 100644
index 000000000000..9e4aad757ce1
--- /dev/null
+++ b/posthog/api/test/__snapshots__/test_persons_trends.new_events_schema.ambr
@@ -0,0 +1,159 @@
+# serializer version: 1
+# name: TestPersonTrends.test_trends_people_endpoint_filters_search[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT source.actor_id AS actor_id,
+ source.event_count AS event_count,
+ source.matching_events AS matching_events,
+ source.event_distinct_ids AS event_distinct_ids
+ 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,
+ 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.`$session_id` AS `$session_id`,
+ e.`$window_id` AS `$window_id`,
+ e.distinct_id AS distinct_id
+ 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 person.id AS id,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name
+ 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 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), or(ifNull(ilike(toString(e__person.properties___email), '%ben%'), 0), ifNull(ilike(toString(e__person.properties___name), '%ben%'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(e.properties.^distinct_id), '{}'), toJSONString(e.properties.^distinct_id), if(isNull(e.properties.distinct_id), NULL, if(startsWith(dynamicType(e.properties.distinct_id), 'DateTime'), replaceOne(toString(e.properties.distinct_id), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.distinct_id), 'Array'), startsWith(dynamicType(e.properties.distinct_id), 'Map'), startsWith(dynamicType(e.properties.distinct_id), 'Tuple')), toJSONString(e.properties.distinct_id), toString(e.properties.distinct_id)))))), '%ben%'), 0)), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), or(isNull(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), ifNull(equals(ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), 400), ''), '$$_posthog_breakdown_null_$$'), '$$_posthog_breakdown_null_$$'), 0)), equals(e.event, '$pageview')))
+ GROUP BY actor_id) AS source
+ ORDER BY source.actor_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: TestPersonTrends.test_trends_people_endpoint_filters_search[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT source.actor_id AS actor_id,
+ source.event_count AS event_count,
+ source.matching_events AS matching_events,
+ source.event_distinct_ids AS event_distinct_ids
+ 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,
+ 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.`$session_id` AS `$session_id`,
+ e.`$window_id` AS `$window_id`,
+ e.distinct_id AS distinct_id
+ 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), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), or(isNull(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), ifNull(equals(ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), 400), ''), '$$_posthog_breakdown_null_$$'), '$$_posthog_breakdown_null_$$'), 0)), equals(e.event, '$pageview')))
+ GROUP BY actor_id) AS source
+ ORDER BY source.actor_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: TestPersonTrends.test_trends_people_endpoint_includes_recordings[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT source.actor_id AS actor_id,
+ source.event_count AS event_count,
+ source.matching_events AS matching_events,
+ source.event_distinct_ids AS event_distinct_ids
+ 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,
+ 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.`$session_id` AS `$session_id`,
+ e.`$window_id` AS `$window_id`,
+ e.distinct_id AS distinct_id
+ 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), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), or(isNull(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), ifNull(equals(ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(startsWith(dynamicType(e.properties.key), 'DateTime'), replaceOne(toString(e.properties.key), ' ', 'T'), if(or(startsWith(dynamicType(e.properties.key), 'Array'), startsWith(dynamicType(e.properties.key), 'Map'), startsWith(dynamicType(e.properties.key), 'Tuple')), toJSONString(e.properties.key), toString(e.properties.key)))))), 400), ''), '$$_posthog_breakdown_null_$$'), '$$_posthog_breakdown_null_$$'), 0)), equals(e.event, '$pageview')))
+ GROUP BY actor_id) AS source
+ ORDER BY source.actor_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/api/test/__snapshots__/test_properties_timeline.ambr b/posthog/api/test/__snapshots__/test_properties_timeline.ambr
index ff758cf1345d..142ab3d9c555 100644
--- a/posthog/api/test/__snapshots__/test_properties_timeline.ambr
+++ b/posthog/api/test/__snapshots__/test_properties_timeline.ambr
@@ -39,46 +39,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes_without_events
'''
/* user_id:0 request:_snapshot_ */
@@ -119,46 +79,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes_without_events[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC'))))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes_without_filters
'''
/* user_id:0 request:_snapshot_ */
@@ -199,46 +119,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes_without_filters[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- '' AS relevant_property_values,
- lagInFrame('') OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_three_events_and_return_to_previous_value
'''
/* user_id:0 request:_snapshot_ */
@@ -279,46 +159,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_three_events_and_return_to_previous_value[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_day_point
'''
/* user_id:0 request:_snapshot_ */
@@ -359,46 +199,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_day_point[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-02 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_hour_point
'''
/* user_id:0 request:_snapshot_ */
@@ -439,46 +239,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_hour_point[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-02 01:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_month_point
'''
/* user_id:0 request:_snapshot_ */
@@ -519,46 +279,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_month_point[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-31 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_using_relative_date_from
'''
/* user_id:0 request:_snapshot_ */
@@ -599,46 +319,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_using_relative_date_from[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-09 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_before_range
'''
/* user_id:0 request:_snapshot_ */
@@ -679,46 +359,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_before_range[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_in_range
'''
/* user_id:0 request:_snapshot_ */
@@ -759,46 +399,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_in_range[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_breakdown
'''
/* user_id:0 request:_snapshot_ */
@@ -839,46 +439,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_breakdown[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_filter_on_series
'''
/* user_id:0 request:_snapshot_ */
@@ -919,43 +479,3 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_filter_on_series[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp AS timestamp,
- properties AS properties,
- minus(end_event_number, start_event_number) AS relevant_event_count
- FROM
- (SELECT timestamp AS timestamp,
- properties AS properties,
- start_event_number AS start_event_number,
- leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
- concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
- toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo))))))) AS relevant_property_values,
- lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo)))))))) OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
- count() OVER () AS total_events
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
- WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
- or isNotNull(previous_relevant_property_values))))
- ORDER BY timestamp ASC
- 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/api/test/__snapshots__/test_properties_timeline.new_events_schema.ambr b/posthog/api/test/__snapshots__/test_properties_timeline.new_events_schema.ambr
new file mode 100644
index 000000000000..ed7fbfc529b3
--- /dev/null
+++ b/posthog/api/test/__snapshots__/test_properties_timeline.new_events_schema.ambr
@@ -0,0 +1,481 @@
+# serializer version: 1
+# name: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes_without_events[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC'))))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_six_events_but_only_two_relevant_changes_without_filters[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ '' AS relevant_property_values,
+ lagInFrame('') OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_actor_with_three_events_and_return_to_previous_value[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_day_point[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-02 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_hour_point[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-02 01:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_at_single_month_point[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-31 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_existing_person_with_three_events_and_return_to_previous_value_using_relative_date_from[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-09 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_before_range[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_in_range[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_breakdown[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_filter_on_series[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT timestamp AS timestamp,
+ properties AS properties,
+ minus(end_event_number, start_event_number) AS relevant_event_count
+ FROM
+ (SELECT timestamp AS timestamp,
+ properties AS properties,
+ start_event_number AS start_event_number,
+ leadInFrame(start_event_number, 1, plus(total_events, 1)) OVER (
+ ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
+ FROM
+ (SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null', JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties)))), ','), '}') AS properties,
+ toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo))))))) AS relevant_property_values,
+ lagInFrame(toString(tuple(if(notEquals(toJSONString(events.person_properties.^bar), '{}'), toJSONString(events.person_properties.^bar), if(isNull(events.person_properties.bar), NULL, if(startsWith(dynamicType(events.person_properties.bar), 'DateTime'), replaceOne(toString(events.person_properties.bar), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.bar), 'Array'), startsWith(dynamicType(events.person_properties.bar), 'Map'), startsWith(dynamicType(events.person_properties.bar), 'Tuple')), toJSONString(events.person_properties.bar), toString(events.person_properties.bar))))), if(notEquals(toJSONString(events.person_properties.^foo), '{}'), toJSONString(events.person_properties.^foo), if(isNull(events.person_properties.foo), NULL, if(startsWith(dynamicType(events.person_properties.foo), 'DateTime'), replaceOne(toString(events.person_properties.foo), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.foo), 'Array'), startsWith(dynamicType(events.person_properties.foo), 'Map'), startsWith(dynamicType(events.person_properties.foo), 'Tuple')), toJSONString(events.person_properties.foo), toString(events.person_properties.foo)))))))) OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
+ row_number() OVER (
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS start_event_number,
+ count() OVER () AS total_events
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.person_id, toUUIDOrNull('12345678-0000-0000-0000-000000000001')), greaterOrEquals(events.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('2020-01-05 23:59:59.999999', 6, 'UTC')), equals(events.event, '$pageview')))
+ WHERE or(equals(start_event_number, 1), ifNull(notEquals(relevant_property_values, previous_relevant_property_values), isNotNull(relevant_property_values)
+ or isNotNull(previous_relevant_property_values))))
+ ORDER BY timestamp ASC
+ 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/api/test/__snapshots__/test_query.ambr b/posthog/api/test/__snapshots__/test_query.ambr
index c5ec28ba4dc1..489bd1f8468f 100644
--- a/posthog/api/test/__snapshots__/test_query.ambr
+++ b/posthog/api/test/__snapshots__/test_query.ambr
@@ -92,99 +92,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_event_property_filter[new_events_schema.1]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key,
- '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), 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 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: TestQuery.test_event_property_filter[new_events_schema.2]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key,
- '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), 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 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: TestQuery.test_event_property_filter[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key,
- '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), 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 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: TestQuery.test_events_query_all_time_date
'''
/* user_id:0 request:_snapshot_ */
@@ -266,315 +173,18 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_events_query_all_time_date[new_events_schema.1]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event
- FROM events_json AS events
- 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 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: TestQuery.test_events_query_all_time_date[new_events_schema.2]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event
- FROM events_json AS events
- 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 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: TestQuery.test_events_query_all_time_date[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event
- FROM events_json AS events
- 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 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: TestQuery.test_full_hogql_query
'''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key
- FROM events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC
- LIMIT 101
- OFFSET 0 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=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: TestQuery.test_full_hogql_query[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key
- FROM events_json AS events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC
- LIMIT 101
- OFFSET 0 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=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: TestQuery.test_full_hogql_query_view
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key
- FROM events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') 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: TestQuery.test_full_hogql_query_view.1
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT event_view.event AS event,
- event_view.distinct_id AS distinct_id,
- event_view.key AS key
- FROM
- (SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key
- FROM events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC) AS event_view
- LIMIT 101
- OFFSET 0 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=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: TestQuery.test_full_hogql_query_view[new_events_schema.1]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT event_view.event AS event,
- event_view.distinct_id AS distinct_id,
- event_view.key AS key
- FROM
- (SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key
- FROM events_json AS events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC) AS event_view
- LIMIT 101
- OFFSET 0 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=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: TestQuery.test_full_hogql_query_view[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key
- FROM events_json AS events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') 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: TestQuery.test_hogql_property_filter
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
- '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), 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 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: TestQuery.test_hogql_property_filter.1
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
- '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 0
- ORDER BY events.event 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: TestQuery.test_hogql_property_filter.2
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
- '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), 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 ASC
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key
+ FROM events
+ WHERE equals(events.team_id, 99999)
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
+ max_execution_time=600,
allow_experimental_object_type=1,
max_ast_elements=4000000,
max_expanded_ast_elements=4000000,
@@ -587,22 +197,15 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_hogql_property_filter.3
+# name: TestQuery.test_full_hogql_query_view
'''
/* user_id:0 request:_snapshot_ */
SELECT events.event AS event,
events.distinct_id AS distinct_id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key
FROM events
- 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 ASC
+ WHERE equals(events.team_id, 99999)
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
max_execution_time=60,
@@ -618,20 +221,22 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_hogql_property_filter[new_events_schema.1]
+# name: TestQuery.test_full_hogql_query_view.1
'''
/* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- 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 key,
- '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 0
- ORDER BY events.event ASC
+ SELECT event_view.event AS event,
+ event_view.distinct_id AS distinct_id,
+ event_view.key AS key
+ FROM
+ (SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key
+ FROM events
+ WHERE equals(events.team_id, 99999)
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC) AS event_view
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
+ max_execution_time=600,
allow_experimental_object_type=1,
max_ast_elements=4000000,
max_expanded_ast_elements=4000000,
@@ -644,18 +249,18 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_hogql_property_filter[new_events_schema.2]
+# name: TestQuery.test_hogql_property_filter
'''
/* user_id:0 request:_snapshot_ */
SELECT events.event AS event,
events.distinct_id AS distinct_id,
- 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 key,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
'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
+ 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), globalIn(events.uuid,
(SELECT events.uuid AS uuid
- FROM events_json AS events
+ 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'))))
@@ -675,21 +280,16 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_hogql_property_filter[new_events_schema.3]
+# name: TestQuery.test_hogql_property_filter.1
'''
/* user_id:0 request:_snapshot_ */
SELECT events.event AS event,
events.distinct_id AS distinct_id,
- 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 key,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
'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), 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'))))
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`
+ FROM events
+ WHERE 0
ORDER BY events.event ASC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -706,18 +306,18 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_hogql_property_filter[new_events_schema]
+# name: TestQuery.test_hogql_property_filter.2
'''
/* user_id:0 request:_snapshot_ */
SELECT events.event AS event,
events.distinct_id AS distinct_id,
- 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 key,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
'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
+ 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), globalIn(events.uuid,
(SELECT events.uuid AS uuid
- FROM events_json AS events
+ 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'))))
@@ -737,7 +337,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_person_property_filter
+# name: TestQuery.test_hogql_property_filter.3
'''
/* user_id:0 request:_snapshot_ */
SELECT events.event AS event,
@@ -746,44 +346,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
- 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), 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')))
+ 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(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'))))
+ 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 ASC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -800,15 +368,15 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_person_property_filter[new_events_schema]
+# name: TestQuery.test_person_property_filter
'''
/* user_id:0 request:_snapshot_ */
SELECT events.event AS event,
events.distinct_id AS distinct_id,
- 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 key,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key,
'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
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) AS `concat(event, ' ', properties.key)`
+ 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
@@ -828,7 +396,7 @@
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), globalIn(events.uuid,
(SELECT events.uuid AS uuid
- FROM events_json AS events
+ 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
@@ -912,55 +480,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_property_filter_aggregations[new_events_schema.1]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT 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 key,
- count() AS `count()`
- 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')))
- GROUP 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)))))
- HAVING greater(count(), 1)
- ORDER BY count() 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: TestQuery.test_property_filter_aggregations[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT 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 key,
- count() AS `count()`
- 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')))
- GROUP 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)))))
- ORDER BY count() 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: TestQuery.test_select_event_person
'''
/* user_id:0 request:_snapshot_ */
@@ -990,35 +509,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_select_event_person[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- events.distinct_id AS distinct_id
- FROM events_json AS events
- 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 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: TestQuery.test_select_hogql_expressions
'''
/* user_id:0 request:_snapshot_ */
@@ -1125,115 +615,3 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_select_hogql_expressions[new_events_schema.1]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`,
- events.event AS event
- FROM events_json AS events
- 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
- 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: TestQuery.test_select_hogql_expressions[new_events_schema.2]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT count() AS `count()`,
- events.event AS event
- 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')))
- GROUP BY events.event
- ORDER BY count() 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: TestQuery.test_select_hogql_expressions[new_events_schema.3]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT count() AS `count()`,
- events.event AS event
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'sign up'), ifNull(like(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))))), '%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')))
- GROUP BY events.event
- ORDER BY count() DESC, events.event 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: TestQuery.test_select_hogql_expressions[new_events_schema]
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT 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 key,
- events.event AS event,
- 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), 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))))) 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/api/test/__snapshots__/test_query.new_events_schema.ambr b/posthog/api/test/__snapshots__/test_query.new_events_schema.ambr
new file mode 100644
index 000000000000..141010209dc2
--- /dev/null
+++ b/posthog/api/test/__snapshots__/test_query.new_events_schema.ambr
@@ -0,0 +1,623 @@
+# serializer version: 1
+# name: TestQuery.test_event_property_filter[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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), 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 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: TestQuery.test_event_property_filter[new_events_schema.2]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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), 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 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: TestQuery.test_event_property_filter[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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), 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 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: TestQuery.test_events_query_all_time_date[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event
+ FROM events_json AS events
+ 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 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: TestQuery.test_events_query_all_time_date[new_events_schema.2]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event
+ FROM events_json AS events
+ 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 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: TestQuery.test_events_query_all_time_date[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event
+ FROM events_json AS events
+ 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 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: TestQuery.test_full_hogql_query[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key
+ FROM events_json AS events
+ WHERE equals(events.team_id, 99999)
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC
+ LIMIT 101
+ OFFSET 0 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=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: TestQuery.test_full_hogql_query_view[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT event_view.event AS event,
+ event_view.distinct_id AS distinct_id,
+ event_view.key AS key
+ FROM
+ (SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key
+ FROM events_json AS events
+ WHERE equals(events.team_id, 99999)
+ ORDER BY toTimeZone(events.timestamp, 'UTC') ASC) AS event_view
+ LIMIT 101
+ OFFSET 0 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=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: TestQuery.test_full_hogql_query_view[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key
+ FROM events_json AS events
+ WHERE equals(events.team_id, 99999)
+ ORDER BY toTimeZone(events.timestamp, 'UTC') 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: TestQuery.test_hogql_property_filter[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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 0
+ ORDER BY events.event 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: TestQuery.test_hogql_property_filter[new_events_schema.2]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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), 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 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: TestQuery.test_hogql_property_filter[new_events_schema.3]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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), 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 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: TestQuery.test_hogql_property_filter[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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), 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 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: TestQuery.test_person_property_filter[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ 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 key,
+ '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
+ 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), 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 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: TestQuery.test_property_filter_aggregations[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT 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 key,
+ count() AS `count()`
+ 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')))
+ GROUP 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)))))
+ HAVING greater(count(), 1)
+ ORDER BY count() 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: TestQuery.test_property_filter_aggregations[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT 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 key,
+ count() AS `count()`
+ 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')))
+ GROUP 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)))))
+ ORDER BY count() 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: TestQuery.test_select_event_person[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT events.event AS event,
+ events.distinct_id AS distinct_id,
+ events.distinct_id AS distinct_id
+ FROM events_json AS events
+ 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 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: TestQuery.test_select_hogql_expressions[new_events_schema.1]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`,
+ events.event AS event
+ FROM events_json AS events
+ 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
+ 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: TestQuery.test_select_hogql_expressions[new_events_schema.2]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT count() AS `count()`,
+ events.event AS event
+ 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')))
+ GROUP BY events.event
+ ORDER BY count() 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: TestQuery.test_select_hogql_expressions[new_events_schema.3]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT count() AS `count()`,
+ events.event AS event
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'sign up'), ifNull(like(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))))), '%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')))
+ GROUP BY events.event
+ ORDER BY count() DESC, events.event 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: TestQuery.test_select_hogql_expressions[new_events_schema]
+ '''
+ /* user_id:0 request:_snapshot_ */
+ SELECT 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 key,
+ events.event AS event,
+ 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), 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))))) 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/hogql/database/schema/util/test/test_session_v2_where_clause_extractor.py b/posthog/hogql/database/schema/util/test/test_session_v2_where_clause_extractor.py
index 46e92b0dce61..1f7c1f73bc06 100644
--- a/posthog/hogql/database/schema/util/test/test_session_v2_where_clause_extractor.py
+++ b/posthog/hogql/database/schema/util/test/test_session_v2_where_clause_extractor.py
@@ -2,7 +2,7 @@ from datetime import UTC, datetime
from typing import Any, Optional, Union
import pytest
-from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event
+from posthog.test.base import APIBaseTest, ClickhouseTestMixin, NewEventsSchemaSnapshotExtension, _create_event
from django.conf import settings
@@ -462,7 +462,9 @@ class TestSessionsV2QueriesHogQLToClickhouse(ClickhouseTestMixin, APIBaseTest):
generalized_sql = self.generalize_sql(actual)
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and "events_json" in generalized_sql:
- assert generalized_sql == self.snapshot(name="new_events_schema")
+ assert generalized_sql == self.snapshot(
+ name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension
+ )
return
assert generalized_sql == self.snapshot
@@ -616,7 +618,9 @@ class TestSessionIdPushdownV2(ClickhouseTestMixin, APIBaseTest):
generalized_sql = self.generalize_sql(actual)
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and "events_json" in generalized_sql:
- assert generalized_sql == self.snapshot(name="new_events_schema")
+ assert generalized_sql == self.snapshot(
+ name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension
+ )
return
assert generalized_sql == self.snapshot
diff --git a/posthog/hogql/database/schema/util/test/test_session_v3_where_clause_extractor.py b/posthog/hogql/database/schema/util/test/test_session_v3_where_clause_extractor.py
index 9fd52b25c61b..1f7adfbad654 100644
--- a/posthog/hogql/database/schema/util/test/test_session_v3_where_clause_extractor.py
+++ b/posthog/hogql/database/schema/util/test/test_session_v3_where_clause_extractor.py
@@ -2,7 +2,7 @@ from datetime import UTC, datetime
from typing import Any, Optional, Union
import pytest
-from posthog.test.base import APIBaseTest, ClickhouseTestMixin
+from posthog.test.base import APIBaseTest, ClickhouseTestMixin, NewEventsSchemaSnapshotExtension
from django.conf import settings
@@ -487,7 +487,9 @@ class TestSessionsV3QueriesHogQLToClickhouse(ClickhouseTestMixin, APIBaseTest):
generalized_sql = self.generalize_sql(actual)
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and "events_json" in generalized_sql:
- assert generalized_sql == self.snapshot(name="new_events_schema")
+ assert generalized_sql == self.snapshot(
+ name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension
+ )
return
assert generalized_sql == self.snapshot
diff --git a/posthog/hogql/database/schema/util/test/test_session_where_clause_extractor.py b/posthog/hogql/database/schema/util/test/test_session_where_clause_extractor.py
index 5959b6f4c541..f1e661795091 100644
--- a/posthog/hogql/database/schema/util/test/test_session_where_clause_extractor.py
+++ b/posthog/hogql/database/schema/util/test/test_session_where_clause_extractor.py
@@ -1,7 +1,7 @@
from typing import Any, Optional, Union
import pytest
-from posthog.test.base import APIBaseTest, ClickhouseTestMixin
+from posthog.test.base import APIBaseTest, ClickhouseTestMixin, NewEventsSchemaSnapshotExtension
from django.conf import settings
@@ -428,7 +428,9 @@ class TestSessionsQueriesHogQLToClickhouse(ClickhouseTestMixin, APIBaseTest):
generalized_sql = self.generalize_sql(actual)
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and "events_json" in generalized_sql:
- assert generalized_sql == self.snapshot(name="new_events_schema")
+ assert generalized_sql == self.snapshot(
+ name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension
+ )
return
assert generalized_sql == self.snapshot
diff --git a/posthog/hogql/printer/test/test_printer.py b/posthog/hogql/printer/test/test_printer.py
index 10a76c2049bb..8814ff99b930 100644
--- a/posthog/hogql/printer/test/test_printer.py
+++ b/posthog/hogql/printer/test/test_printer.py
@@ -9,6 +9,7 @@ from posthog.test.base import (
APIBaseTest,
BaseTest,
ClickhouseTestMixin,
+ NewEventsSchemaSnapshotExtension,
_create_event,
_create_person,
clean_varying_query_parts,
@@ -197,7 +198,7 @@ class TestPrinter(BaseTest):
def _schema_snapshot(self):
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- return self.snapshot(name="new_events_schema")
+ return self.snapshot(name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _assert_expr_error(
diff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.py
index 87a0faa9a776..832deb3f9295 100644
--- a/posthog/hogql/test/test_query.py
+++ b/posthog/hogql/test/test_query.py
@@ -6,7 +6,14 @@ from zoneinfo import ZoneInfo
import pytest
from freezegun import freeze_time
-from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event, _create_person, flush_persons_and_events
+from posthog.test.base import (
+ APIBaseTest,
+ ClickhouseTestMixin,
+ NewEventsSchemaSnapshotExtension,
+ _create_event,
+ _create_person,
+ flush_persons_and_events,
+)
from unittest.mock import patch
from django.conf import settings
@@ -63,7 +70,7 @@ class TestQuery(ClickhouseTestMixin, APIBaseTest):
snapshot_index = getattr(self, "_new_events_schema_snapshot_index", 0)
self._new_events_schema_snapshot_index = snapshot_index + 1
snapshot_name = "new_events_schema" if snapshot_index == 0 else f"new_events_schema.{snapshot_index}"
- return self.snapshot(name=snapshot_name)
+ return self.snapshot(name=snapshot_name, extension_class=NewEventsSchemaSnapshotExtension)
def assertResponseMatchesSnapshot(self, response) -> None:
snapshot_value = pretty_print_response_in_tests(response, self.team.pk)
diff --git a/posthog/hogql/transforms/test/test_events_predicate_pushdown.py b/posthog/hogql/transforms/test/test_events_predicate_pushdown.py
index 6227d79bd5a0..1044be850aec 100644
--- a/posthog/hogql/transforms/test/test_events_predicate_pushdown.py
+++ b/posthog/hogql/transforms/test/test_events_predicate_pushdown.py
@@ -8,6 +8,7 @@ from posthog.test.base import (
APIBaseTest,
BaseTest,
ClickhouseTestMixin,
+ NewEventsSchemaSnapshotExtension,
_create_event,
_create_person,
flush_persons_and_events,
@@ -66,7 +67,7 @@ class TestEventsPredicatePushdownTransform(BaseTest):
def _events_schema_snapshot(self):
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- return self.snapshot(name="new_events_schema")
+ return self.snapshot(name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _print_select(self, select: str, modifiers: HogQLQueryModifiers | None = None):
@@ -1004,7 +1005,7 @@ class _PushdownExecutionTestBase(ClickhouseTestMixin, APIBaseTest):
def _events_schema_snapshot(self):
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- return self.snapshot(name="new_events_schema")
+ return self.snapshot(name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _assert_events_property_source(self, subquery: str, property_name: str, legacy_column: str) -> None:
diff --git a/posthog/hogql/transforms/test/test_in_cohort.py b/posthog/hogql/transforms/test/test_in_cohort.py
index 5cb92ba70bc1..41875946d678 100644
--- a/posthog/hogql/transforms/test/test_in_cohort.py
+++ b/posthog/hogql/transforms/test/test_in_cohort.py
@@ -1,7 +1,14 @@
from typing import Any
import pytest
-from posthog.test.base import BaseTest, QueryMatchingTest, _create_event, _create_person, flush_persons_and_events
+from posthog.test.base import (
+ BaseTest,
+ NewEventsSchemaSnapshotExtension,
+ QueryMatchingTest,
+ _create_event,
+ _create_person,
+ flush_persons_and_events,
+)
from django.conf import settings
from django.test import override_settings
@@ -36,7 +43,7 @@ class EventsSchemaSnapshotMixin:
snapshot_index = getattr(self, "_new_events_schema_snapshot_index", 0)
self._new_events_schema_snapshot_index = snapshot_index + 1
snapshot_name = "new_events_schema" if snapshot_index == 0 else f"new_events_schema.{snapshot_index}"
- return self.snapshot(name=snapshot_name)
+ return self.snapshot(name=snapshot_name, extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _assert_response_matches_snapshot(self, response) -> None:
diff --git a/posthog/hogql/transforms/test/test_lazy_tables.py b/posthog/hogql/transforms/test/test_lazy_tables.py
index dac03355491e..d61ba2becacd 100644
--- a/posthog/hogql/transforms/test/test_lazy_tables.py
+++ b/posthog/hogql/transforms/test/test_lazy_tables.py
@@ -1,7 +1,7 @@
from typing import Any
import pytest
-from posthog.test.base import BaseTest
+from posthog.test.base import BaseTest, NewEventsSchemaSnapshotExtension
from django.conf import settings
from django.test import override_settings
@@ -23,7 +23,7 @@ class TestLazyJoins(BaseTest):
def _schema_snapshot(self, printed: str):
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and "events_json" in printed:
- return self.snapshot(name="new_events_schema")
+ return self.snapshot(name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _assert_matches_snapshot(self, printed: str) -> None:
diff --git a/posthog/hogql/transforms/test/test_property_types.py b/posthog/hogql/transforms/test/test_property_types.py
index e448839f36e3..5c043d8bd588 100644
--- a/posthog/hogql/transforms/test/test_property_types.py
+++ b/posthog/hogql/transforms/test/test_property_types.py
@@ -8,6 +8,7 @@ import pytest
from posthog.test.base import (
BaseTest,
ClickhouseTestMixin,
+ NewEventsSchemaSnapshotExtension,
_create_event,
flush_persons_and_events,
get_indexes_from_explain,
@@ -291,7 +292,7 @@ class TestPropertyTypes(BaseTest):
def _events_schema_snapshot(self):
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- return self.snapshot(name="new_events_schema")
+ return self.snapshot(name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _plan_where_comparison(
diff --git a/posthog/hogql/transforms/test/test_state_aggregations.py b/posthog/hogql/transforms/test/test_state_aggregations.py
index 2120838ceac2..ec51ce22571a 100644
--- a/posthog/hogql/transforms/test/test_state_aggregations.py
+++ b/posthog/hogql/transforms/test/test_state_aggregations.py
@@ -2,7 +2,14 @@ from datetime import datetime
from typing import Any
import pytest
-from posthog.test.base import APIBaseTest, BaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events
+from posthog.test.base import (
+ APIBaseTest,
+ BaseTest,
+ ClickhouseTestMixin,
+ NewEventsSchemaSnapshotExtension,
+ _create_event,
+ flush_persons_and_events,
+)
from django.conf import settings
@@ -26,7 +33,7 @@ class TestStateTransforms(BaseTest):
def _schema_snapshot(self, printed: str):
self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = True
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and "events_json" in printed:
- return self.snapshot(name="new_events_schema")
+ return self.snapshot(name="new_events_schema", extension_class=NewEventsSchemaSnapshotExtension)
return self.snapshot
def _assert_matches_snapshot(self, printed: str) -> None:
diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation_actors.new_events_schema.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation_actors.new_events_schema.ambr
new file mode 100644
index 000000000000..6e0d81b6f901
--- /dev/null
+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation_actors.new_events_schema.ambr
@@ -0,0 +1,256 @@
+# serializer version: 1
+# name: TestFunnelCorrelationActors.test_funnel_correlation_on_event_with_recordings[new_events_schema.1]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (WITH funnel_actors AS
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[plus(step_reached, 1)] AS matching_events,
+ (matched_events_array[1][1]).1 AS timestamp,
+ nullIf((matched_events_array[3][1]).1, 0) AS final_timestamp,
+ (matched_events_array[1][1]).1 AS first_timestamp,
+ steps AS steps
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 1209600, 'first_touch', 'ordered', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '$pageview'), 1, 0) AS step_0,
+ if(equals(e.event, 'insight analyzed'), 1, 0) AS step_1,
+ if(equals(e.event, 'insight updated'), 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('$pageview', 'insight analyzed', 'insight updated'))), 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 bitTest(steps_bitfield, 0)
+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto'),
+ assumeNotNull(toDateTime('2021-01-01 00:00:00', 'UTC')) AS date_from,
+ assumeNotNull(toDateTime('2021-01-08 23:59:59', 'UTC')) AS date_to,
+ 3 AS target_step,
+ ['$pageview', 'insight analyzed', 'insight updated'] AS funnel_step_names SELECT funnel_actors.actor_id AS actor_id,
+ any(funnel_actors.matching_events) AS matching_events,
+ actor_id AS id
+ FROM events_json AS event
+ 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 event__override ON equals(event.distinct_id, event__override.distinct_id)
+ JOIN funnel_actors ON equals(if(not(empty(event__override.distinct_id)), event__override.person_id, event.person_id), funnel_actors.actor_id)
+ WHERE and(equals(event.team_id, 99999), greaterOrEquals(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), date_from), less(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), date_to), equals(event.team_id, 99999), greater(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), toTimeZone(funnel_actors.first_timestamp, 'UTC')), less(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), coalesce(toTimeZone(funnel_actors.final_timestamp, 'UTC'), plus(toTimeZone(toTimeZone(funnel_actors.first_timestamp, 'UTC'), 'UTC'), toIntervalDay(14)), date_to)), notIn(event.event, funnel_step_names), equals(event.event, 'insight loaded'), ifNull(notEquals(funnel_actors.steps, target_step), isNotNull(funnel_actors.steps)
+ or isNotNull(target_step)))
+ GROUP BY actor_id
+ ORDER BY actor_id ASC) 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: TestFunnelCorrelationActors.test_funnel_correlation_on_event_with_recordings[new_events_schema]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (WITH funnel_actors AS
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[plus(step_reached, 1)] AS matching_events,
+ (matched_events_array[1][1]).1 AS timestamp,
+ nullIf((matched_events_array[2][1]).1, 0) AS final_timestamp,
+ (matched_events_array[1][1]).1 AS first_timestamp,
+ steps AS steps
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
+ [''] AS prop,
+ arrayJoin(aggregate_funnel(2, 1209600, 'first_touch', 'ordered', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '$pageview'), 1, 0) AS step_0,
+ if(equals(e.event, 'insight analyzed'), 1, 0) AS step_1
+ 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('$pageview', 'insight analyzed'))), or(equals(step_0, 1), equals(step_1, 1))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 0)
+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto'),
+ assumeNotNull(toDateTime('2021-01-01 00:00:00', 'UTC')) AS date_from,
+ assumeNotNull(toDateTime('2021-01-08 23:59:59', 'UTC')) AS date_to,
+ 2 AS target_step,
+ ['$pageview', 'insight analyzed'] AS funnel_step_names SELECT funnel_actors.actor_id AS actor_id,
+ any(funnel_actors.matching_events) AS matching_events,
+ actor_id AS id
+ FROM events_json AS event
+ 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 event__override ON equals(event.distinct_id, event__override.distinct_id)
+ JOIN funnel_actors ON equals(if(not(empty(event__override.distinct_id)), event__override.person_id, event.person_id), funnel_actors.actor_id)
+ WHERE and(equals(event.team_id, 99999), greaterOrEquals(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), date_from), less(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), date_to), equals(event.team_id, 99999), greater(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), toTimeZone(funnel_actors.first_timestamp, 'UTC')), less(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), coalesce(toTimeZone(funnel_actors.final_timestamp, 'UTC'), plus(toTimeZone(toTimeZone(funnel_actors.first_timestamp, 'UTC'), 'UTC'), toIntervalDay(14)), date_to)), notIn(event.event, funnel_step_names), equals(event.event, 'insight loaded'), ifNull(equals(funnel_actors.steps, target_step), isNull(funnel_actors.steps)
+ and isNull(target_step)))
+ GROUP BY actor_id
+ ORDER BY actor_id ASC) 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: TestFunnelCorrelationActors.test_funnel_correlation_on_properties_with_recordings[new_events_schema]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (WITH funnel_actors AS
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[plus(step_reached, 1)] AS matching_events,
+ (matched_events_array[1][1]).1 AS timestamp,
+ nullIf((matched_events_array[2][1]).1, 0) AS final_timestamp,
+ (matched_events_array[1][1]).1 AS first_timestamp,
+ steps AS steps
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
+ [''] AS prop,
+ arrayJoin(aggregate_funnel(2, 1209600, 'first_touch', 'ordered', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '$pageview'), 1, 0) AS step_0,
+ if(equals(e.event, 'insight analyzed'), 1, 0) AS step_1
+ 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 person.id AS id,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'foo'), ''), 'null'), '^"|"$', '') AS properties___foo
+ 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 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), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'insight analyzed')), ifNull(equals(e__person.properties___foo, 'bar'), 0)), or(equals(step_0, 1), equals(step_1, 1))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 0)
+ ORDER BY aggregation_target ASC SETTINGS join_algorithm='auto'),
+ 2 AS target_step SELECT funnel_actors.actor_id AS actor_id,
+ any(funnel_actors.matching_events) AS matching_events,
+ actor_id AS id
+ FROM funnel_actors
+ WHERE ifNull(equals(funnel_actors.steps, target_step), isNull(funnel_actors.steps)
+ and isNull(target_step))
+ GROUP BY funnel_actors.actor_id
+ ORDER BY funnel_actors.actor_id ASC) 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_data_warehouse.new_events_schema.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_data_warehouse.new_events_schema.ambr
new file mode 100644
index 000000000000..c815aeae725e
--- /dev/null
+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_data_warehouse.new_events_schema.ambr
@@ -0,0 +1,243 @@
+# serializer version: 1
+# name: TestFunnelDataWarehouse.test_funnels_data_warehouse_and_regular_nodes[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,
+ breakdown AS final_prop
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
+ [''] AS prop,
+ arrayJoin(aggregate_funnel(2, 1209600, 'first_touch', 'ordered', 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 e.timestamp AS timestamp,
+ e.aggregation_target AS aggregation_target,
+ e.uuid AS uuid,
+ e.`$session_id` AS `$session_id`,
+ e.`$window_id` AS `$window_id`,
+ e.step_0 AS step_0,
+ e.step_1 AS step_1
+ FROM
+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
+ toString(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, '$pageview'), 1, 0) AS step_0,
+ 0 AS step_1
+ 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('$pageview'))), equals(step_0, 1))
+ UNION ALL SELECT toTimeZone(e.created, 'UTC') AS timestamp,
+ toString(accurateCastOrNull(e.user_id, 'UUID')) AS aggregation_target,
+ tupleElement(tuple(throwIf(isNull(e.uuid), 'Encountered a null value in posthog_test_test_table_1.uuid, but a non-null value is required. Please ensure this column contains no null values, or add a filter to exclude rows with null values.'), toUUIDOrDefault(toString(e.uuid), reinterpretAsUUID(hex(MD5(concat('posthog_test_test_table_1_0_', ifNull(toString(e.uuid), ''))))))), 2) AS uuid,
+ NULL AS `$session_id`,
+ NULL AS `$window_id`,
+ 0 AS step_0,
+ if(1, 1, 0) AS step_1
+ FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql_queries.insights.funnels.funnel_data_warehouse/posthog_test_test_table_1/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Int64, `uuid` String, `created` DateTime64(3, \'UTC\'), `user_id` String, `event_name` String, `id_decimal` Decimal(18, 2), `properties` Nullable(String), `id_with_nulls` Nullable(Int64)') AS e
+ WHERE and(and(greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(step_1, 1))) AS e)
+ 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 100 SETTINGS join_algorithm='auto',
+ format_csv_allow_double_quotes=1,
+ 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: TestFunnelDataWarehouse.test_funnels_data_warehouse_and_regular_nodes_string_aggregation_target[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,
+ breakdown AS final_prop
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
+ [''] AS prop,
+ arrayJoin(aggregate_funnel(2, 1209600, 'first_touch', 'ordered', 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 e.timestamp AS timestamp,
+ e.aggregation_target AS aggregation_target,
+ e.uuid AS uuid,
+ e.`$session_id` AS `$session_id`,
+ e.`$window_id` AS `$window_id`,
+ e.step_0 AS step_0,
+ e.step_1 AS step_1
+ FROM
+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
+ toString(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, '$pageview'), 1, 0) AS step_0,
+ 0 AS step_1
+ 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('$pageview'))), equals(step_0, 1))
+ UNION ALL SELECT toTimeZone(e.created, 'UTC') AS timestamp,
+ toString(e.user_id) AS aggregation_target,
+ tupleElement(tuple(throwIf(isNull(e.uuid), 'Encountered a null value in posthog_test_test_table_1.uuid, but a non-null value is required. Please ensure this column contains no null values, or add a filter to exclude rows with null values.'), toUUIDOrDefault(toString(e.uuid), reinterpretAsUUID(hex(MD5(concat('posthog_test_test_table_1_0_', ifNull(toString(e.uuid), ''))))))), 2) AS uuid,
+ NULL AS `$session_id`,
+ NULL AS `$window_id`,
+ 0 AS step_0,
+ if(1, 1, 0) AS step_1
+ FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql_queries.insights.funnels.funnel_data_warehouse/posthog_test_test_table_1/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Int64, `uuid` String, `created` DateTime64(3, \'UTC\'), `user_id` String, `event_name` String, `id_decimal` Decimal(18, 2), `properties` Nullable(String), `id_with_nulls` Nullable(Int64)') AS e
+ WHERE and(and(greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(step_1, 1))) AS e)
+ 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 100 SETTINGS join_algorithm='auto',
+ format_csv_allow_double_quotes=1,
+ 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: TestFunnelDataWarehouse.test_funnels_data_warehouse_and_regular_nodes_string_aggregation_target_actors[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'), uuid, '', arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
+ [''] AS prop,
+ arrayJoin(aggregate_funnel(2, 1209600, 'first_touch', 'ordered', 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 e.timestamp AS timestamp,
+ e.aggregation_target AS aggregation_target,
+ e.uuid AS uuid,
+ e.`$session_id` AS `$session_id`,
+ e.`$window_id` AS `$window_id`,
+ e.step_0 AS step_0,
+ e.step_1 AS step_1
+ FROM
+ (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
+ toString(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, '$pageview'), 1, 0) AS step_0,
+ 0 AS step_1
+ 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('$pageview'))), equals(step_0, 1))
+ UNION ALL SELECT toTimeZone(e.created, 'UTC') AS timestamp,
+ toString(e.user_id) AS aggregation_target,
+ tupleElement(tuple(throwIf(isNull(e.uuid), 'Encountered a null value in posthog_test_test_table_1.uuid, but a non-null value is required. Please ensure this column contains no null values, or add a filter to exclude rows with null values.'), toUUIDOrDefault(toString(e.uuid), reinterpretAsUUID(hex(MD5(concat('posthog_test_test_table_1_0_', ifNull(toString(e.uuid), ''))))))), 2) AS uuid,
+ NULL AS `$session_id`,
+ NULL AS `$window_id`,
+ 0 AS step_0,
+ if(1, 1, 0) AS step_1
+ FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql_queries.insights.funnels.funnel_data_warehouse/posthog_test_test_table_1/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Int64, `uuid` String, `created` DateTime64(3, \'UTC\'), `user_id` String, `event_name` String, `id_decimal` Decimal(18, 2), `properties` Nullable(String), `id_with_nulls` Nullable(Int64)') AS e
+ WHERE and(and(greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), equals(step_1, 1))) AS e)
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 1)
+ 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',
+ format_csv_allow_double_quotes=1,
+ 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_persons.new_events_schema.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.new_events_schema.ambr
new file mode 100644
index 000000000000..8aec10f1d23b
--- /dev/null
+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.new_events_schema.ambr
@@ -0,0 +1,190 @@
+# serializer version: 1
+# name: TestFunnelPersons.test_funnel_person_recordings[new_events_schema.1]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[2] AS matching_events,
+ actor_id AS id
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 604800, 'first_touch', 'ordered', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '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
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 1)
+ 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: TestFunnelPersons.test_funnel_person_recordings[new_events_schema.2]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[2] AS matching_events,
+ actor_id AS id
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 604800, 'first_touch', 'ordered', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '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
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE and(bitTest(steps_bitfield, 1), not(bitTest(steps_bitfield, 2)))
+ 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: TestFunnelPersons.test_funnel_person_recordings[new_events_schema]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[1] AS matching_events,
+ actor_id AS id
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 604800, 'first_touch', 'ordered', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '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
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 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_strict.new_events_schema.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.new_events_schema.ambr
new file mode 100644
index 000000000000..4608b6911d5a
--- /dev/null
+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.new_events_schema.ambr
@@ -0,0 +1,646 @@
+# serializer version: 1
+# name: TestFunnelStrictStepsBreakdown.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', 'strict', [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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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: TestFunnelStrictStepsBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen_for_step[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,
+ groupUniqArrayIf(arrayMap(x -> ifNull(x, ''), prop), notEmpty(prop)) AS prop,
+ arrayJoin(aggregate_funnel_array(2, 1209600, 'step_1', 'strict', 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,
+ if(equals(step_1, 1), 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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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: TestFunnelStrictStepsBreakdown.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', 'strict', [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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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: TestStrictFunnelGroupBreakdown.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', 'strict', 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(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'))), and(notEquals(toString(aggregation_target), ''), isNotNull(aggregation_target))))
+ 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: TestStrictFunnelGroupBreakdown.test_funnel_breakdown_group[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'), 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', 'strict', 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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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: TestStrictFunnelGroupBreakdown.test_funnel_breakdown_group[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'), 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', 'strict', 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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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: TestStrictFunnelGroupBreakdown.test_funnel_breakdown_group[new_events_schema.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', 'strict', 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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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: TestStrictFunnelGroupBreakdown.test_funnel_breakdown_group[new_events_schema.4]
+ '''
+ 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', 'strict', 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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ 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=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: TestStrictFunnelGroupBreakdown.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', 'strict', 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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ 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
+ '''
+# ---
diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.new_events_schema.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.new_events_schema.ambr
new file mode 100644
index 000000000000..da0da5c96f8f
--- /dev/null
+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.new_events_schema.ambr
@@ -0,0 +1,190 @@
+# serializer version: 1
+# name: TestFunnelStrictStepsPersons.test_strict_funnel_person_recordings[new_events_schema.1]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[2] AS matching_events,
+ actor_id AS id
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 1209600, 'first_touch', 'strict', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 1)
+ 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: TestFunnelStrictStepsPersons.test_strict_funnel_person_recordings[new_events_schema.2]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[2] AS matching_events,
+ actor_id AS id
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 1209600, 'first_touch', 'strict', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE and(bitTest(steps_bitfield, 1), not(bitTest(steps_bitfield, 2)))
+ 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: TestFunnelStrictStepsPersons.test_strict_funnel_person_recordings[new_events_schema]
+ '''
+ SELECT source.id,
+ source.id AS id,
+ source.matching_events AS matching_events
+ FROM
+ (SELECT aggregation_target AS actor_id,
+ matched_events_array[1] AS matching_events,
+ actor_id AS id
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 1209600, 'first_touch', 'strict', 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.4 AS matched_event_uuids_array_array,
+ groupArray(tuple(timestamp, uuid, `$session_id`, `$window_id`)) AS user_events,
+ mapFromArrays(arrayMap(x -> x.2, user_events), user_events) AS user_events_map,
+ arrayMap(matched_event_uuids_array -> arrayMap(event_uuid -> user_events_map[event_uuid], arrayDistinct(matched_event_uuids_array)), matched_event_uuids_array_array) AS matched_events_array,
+ 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, '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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE bitTest(steps_bitfield, 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_time_to_convert.new_events_schema.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.new_events_schema.ambr
new file mode 100644
index 000000000000..c1b8619de26e
--- /dev/null
+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.new_events_schema.ambr
@@ -0,0 +1,196 @@
+# serializer version: 1
+# name: TestFunnelTimeToConvert.test_auto_bin_count_single_step[new_events_schema]
+ '''
+ SELECT bin_from_seconds,
+ person_count,
+ arrayAvg(timings) AS averageConversionTime,
+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTime
+ FROM
+ (SELECT timings AS timings,
+ accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,
+ floor(arrayMin(timings)) AS min_timing,
+ ceil(arrayMax(timings)) AS max_timing,
+ ceil(divide(minus(max_timing, min_timing), bin_count)) AS bin_width_seconds_raw,
+ if(ifNull(greater(bin_width_seconds_raw, 0), 0), bin_width_seconds_raw, 60) AS bin_width_seconds,
+ arrayMap(n -> accurateCastOrNull(round(plus(min_timing, multiply(n, bin_width_seconds))), 'Int64'), range(0, plus(bin_count, 1))) AS buckets,
+ arrayMap(timing -> accurateCastOrNull(floor(divide(minus(timing, min_timing), bin_width_seconds)), 'Int64'), timings) AS indices,
+ arrayMap(x -> countEqual(indices, minus(x, 1)), range(1, plus(bin_count, 2))) AS counts
+ FROM
+ (SELECT groupArray(arraySum(arraySlice(timings, 1, 1))) AS timings
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 604800, 'first_touch', 'ordered', 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, '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
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE ifNull(greaterOrEquals(step_reached, 1), 0))) ARRAY
+ JOIN counts AS person_count,
+ buckets AS bin_from_seconds
+ 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=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: TestFunnelTimeToConvert.test_basic_strict[new_events_schema]
+ '''
+ SELECT bin_from_seconds,
+ person_count,
+ arrayAvg(timings) AS averageConversionTime,
+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTime
+ FROM
+ (SELECT timings AS timings,
+ accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,
+ floor(arrayMin(timings)) AS min_timing,
+ ceil(arrayMax(timings)) AS max_timing,
+ ceil(divide(minus(max_timing, min_timing), bin_count)) AS bin_width_seconds_raw,
+ if(ifNull(greater(bin_width_seconds_raw, 0), 0), bin_width_seconds_raw, 60) AS bin_width_seconds,
+ arrayMap(n -> accurateCastOrNull(round(plus(min_timing, multiply(n, bin_width_seconds))), 'Int64'), range(0, plus(bin_count, 1))) AS buckets,
+ arrayMap(timing -> accurateCastOrNull(floor(divide(minus(timing, min_timing), bin_width_seconds)), 'Int64'), timings) AS indices,
+ arrayMap(x -> countEqual(indices, minus(x, 1)), range(1, plus(bin_count, 2))) AS counts
+ FROM
+ (SELECT groupArray(arraySum(arraySlice(timings, 1, 1))) AS timings
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 604800, 'first_touch', 'strict', 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, '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(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))
+ GROUP BY aggregation_target
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE ifNull(greaterOrEquals(step_reached, 1), 0))) ARRAY
+ JOIN counts AS person_count,
+ buckets AS bin_from_seconds
+ 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=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: TestFunnelTimeToConvert.test_basic_unordered[new_events_schema]
+ '''
+ SELECT bin_from_seconds,
+ person_count,
+ arrayAvg(timings) AS averageConversionTime,
+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTime
+ FROM
+ (SELECT timings AS timings,
+ accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,
+ floor(arrayMin(timings)) AS min_timing,
+ ceil(arrayMax(timings)) AS max_timing,
+ ceil(divide(minus(max_timing, min_timing), bin_count)) AS bin_width_seconds_raw,
+ if(ifNull(greater(bin_width_seconds_raw, 0), 0), bin_width_seconds_raw, 60) AS bin_width_seconds,
+ arrayMap(n -> accurateCastOrNull(round(plus(min_timing, multiply(n, bin_width_seconds))), 'Int64'), range(0, plus(bin_count, 1))) AS buckets,
+ arrayMap(timing -> accurateCastOrNull(floor(divide(minus(timing, min_timing), bin_width_seconds)), 'Int64'), timings) AS indices,
+ arrayMap(x -> countEqual(indices, minus(x, 1)), range(1, plus(bin_count, 2))) AS counts
+ FROM
+ (SELECT groupArray(arraySum(arraySlice(timings, 1, 1))) AS timings
+ FROM
+ (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), 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(3, 604800, '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), 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, '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
+ HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
+ WHERE ifNull(greaterOrEquals(step_reached, 1), 0))) ARRAY
+ JOIN counts AS person_count,
+ buckets AS bin_from_seconds
+ 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=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/test/__snapshots__/test_events_query_runner.new_events_schema.ambr b/posthog/hogql_queries/test/__snapshots__/test_events_query_runner.new_events_schema.ambr
new file mode 100644
index 000000000000..edf4bb82e030
--- /dev/null
+++ b/posthog/hogql_queries/test/__snapshots__/test_events_query_runner.new_events_schema.ambr
@@ -0,0 +1,409 @@
+# serializer version: 1
+# name: TestEventsQueryRunner.test_absolute_date_range[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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), 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
+ 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
+ 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: TestEventsQueryRunner.test_cursor_not_returned_for_aggregation_query[new_events_schema]
+ '''
+ SELECT count() AS `count()`,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ FROM events_json AS 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')))
+ GROUP BY toTimeZone(events.timestamp, 'UTC')
+ ORDER BY count() DESC
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_not_returned_for_non_timestamp_order[new_events_schema]
+ '''
+ SELECT events.event AS event,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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 ASC
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_pagination_multi_page_asc[new_events_schema.1]
+ '''
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(startsWith(dynamicType(events.properties.idx), 'DateTime'), replaceOne(toString(events.properties.idx), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.idx), 'Array'), startsWith(dynamicType(events.properties.idx), 'Map'), startsWith(dynamicType(events.properties.idx), 'Tuple')), toJSONString(events.properties.idx), toString(events.properties.idx))))) AS idx,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_pagination_multi_page_asc[new_events_schema.2]
+ '''
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(startsWith(dynamicType(events.properties.idx), 'DateTime'), replaceOne(toString(events.properties.idx), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.idx), 'Array'), startsWith(dynamicType(events.properties.idx), 'Map'), startsWith(dynamicType(events.properties.idx), 'Tuple')), toJSONString(events.properties.idx), toString(events.properties.idx))))) AS idx,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_pagination_multi_page_asc[new_events_schema]
+ '''
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(startsWith(dynamicType(events.properties.idx), 'DateTime'), replaceOne(toString(events.properties.idx), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.idx), 'Array'), startsWith(dynamicType(events.properties.idx), 'Map'), startsWith(dynamicType(events.properties.idx), 'Tuple')), toJSONString(events.properties.idx), toString(events.properties.idx))))) AS idx,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_pagination_multi_page_desc[new_events_schema.1]
+ '''
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(startsWith(dynamicType(events.properties.idx), 'DateTime'), replaceOne(toString(events.properties.idx), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.idx), 'Array'), startsWith(dynamicType(events.properties.idx), 'Map'), startsWith(dynamicType(events.properties.idx), 'Tuple')), toJSONString(events.properties.idx), toString(events.properties.idx))))) AS idx,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_pagination_multi_page_desc[new_events_schema.2]
+ '''
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(startsWith(dynamicType(events.properties.idx), 'DateTime'), replaceOne(toString(events.properties.idx), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.idx), 'Array'), startsWith(dynamicType(events.properties.idx), 'Map'), startsWith(dynamicType(events.properties.idx), 'Tuple')), toJSONString(events.properties.idx), toString(events.properties.idx))))) AS idx,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_pagination_multi_page_desc[new_events_schema]
+ '''
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(startsWith(dynamicType(events.properties.idx), 'DateTime'), replaceOne(toString(events.properties.idx), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.idx), 'Array'), startsWith(dynamicType(events.properties.idx), 'Map'), startsWith(dynamicType(events.properties.idx), 'Tuple')), toJSONString(events.properties.idx), toString(events.properties.idx))))) AS idx,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_cursor_with_star_select[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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-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
+ 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
+ LIMIT 3
+ 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: TestEventsQueryRunner.test_element_chain_property_filter[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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), 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
+ 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
+ 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: TestEventsQueryRunner.test_presorted_events_table[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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.^some_prop), '{}'), toJSONString(events.properties.^some_prop), if(isNull(events.properties.some_prop), NULL, if(startsWith(dynamicType(events.properties.some_prop), 'DateTime'), replaceOne(toString(events.properties.some_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.some_prop), 'Array'), startsWith(dynamicType(events.properties.some_prop), 'Map'), startsWith(dynamicType(events.properties.some_prop), 'Tuple')), toJSONString(events.properties.some_prop), toString(events.properties.some_prop))))), '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
+ LIMIT 101)), and(ifNull(equals(if(notEquals(toJSONString(events.properties.^some_prop), '{}'), toJSONString(events.properties.^some_prop), if(isNull(events.properties.some_prop), NULL, if(startsWith(dynamicType(events.properties.some_prop), 'DateTime'), replaceOne(toString(events.properties.some_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.some_prop), 'Array'), startsWith(dynamicType(events.properties.some_prop), 'Map'), startsWith(dynamicType(events.properties.some_prop), 'Tuple')), toJSONString(events.properties.some_prop), toString(events.properties.some_prop))))), '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
+ 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: TestEventsQueryRunner.test_presorted_events_table_multiple_order_by[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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), 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
+ 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
+ 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: TestEventsQueryRunner.test_presorted_events_table_order_by_event[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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('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 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: TestEventsQueryRunner.test_presorted_events_table_order_by_property[new_events_schema]
+ '''
+ SELECT 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) AS `tuple(uuid, event, properties, toTimeZone(timestamp, 'UTC'), team_id, distinct_id, elements_chain, toTimeZone(created_at, 'UTC'), person_mode)`
+ 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), 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 if(notEquals(toJSONString(events.properties.^priority), '{}'), toJSONString(events.properties.^priority), if(isNull(events.properties.priority), NULL, if(startsWith(dynamicType(events.properties.priority), 'DateTime'), replaceOne(toString(events.properties.priority), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.priority), 'Array'), startsWith(dynamicType(events.properties.priority), 'Map'), startsWith(dynamicType(events.properties.priority), 'Tuple')), toJSONString(events.properties.priority), toString(events.properties.priority))))) 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 if(notEquals(toJSONString(events.properties.^priority), '{}'), toJSONString(events.properties.^priority), if(isNull(events.properties.priority), NULL, if(startsWith(dynamicType(events.properties.priority), 'DateTime'), replaceOne(toString(events.properties.priority), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.priority), 'Array'), startsWith(dynamicType(events.properties.priority), 'Map'), startsWith(dynamicType(events.properties.priority), 'Tuple')), toJSONString(events.properties.priority), toString(events.properties.priority))))) 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/hogql_queries/test/__snapshots__/test_sessions_query_runner.new_events_schema.ambr b/posthog/hogql_queries/test/__snapshots__/test_sessions_query_runner.new_events_schema.ambr
new file mode 100644
index 000000000000..8abe06d5f81c
--- /dev/null
+++ b/posthog/hogql_queries/test/__snapshots__/test_sessions_query_runner.new_events_schema.ambr
@@ -0,0 +1,31 @@
+# serializer version: 1
+# name: TestSessionsQueryRunner.test_filter_by_event_properties_without_event_name[new_events_schema]
+ '''
+ SELECT sessions.session_id AS session_id
+ FROM
+ (SELECT toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7, 64), bitShiftRight(raw_sessions.session_id_v7, 64)))) AS session_id,
+ min(toTimeZone(raw_sessions.min_timestamp, 'UTC')) AS `$start_timestamp`,
+ raw_sessions.session_id_v7 AS session_id_v7
+ FROM raw_sessions
+ WHERE and(equals(raw_sessions.team_id, 99999), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(toDateTime64('2024-01-01 14:00:05.000000', 6, 'UTC'), toIntervalDay(3))), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(toDateTime64('2024-01-01 00:00:00.000000', 6, 'UTC'), toIntervalDay(3))))
+ GROUP BY raw_sessions.session_id_v7) AS sessions
+ WHERE and(globalIn(sessions.session_id,
+ (SELECT DISTINCT events.`$session_id` AS `$session_id`
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), and(equals(events.properties.`$current_url`, 'https://example.com/pricing'), isNotNull(events.properties.`$current_url`)), greater(events.timestamp, toDateTime64('2024-01-01 00:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('2024-01-01 14:00:05.000000', 6, 'UTC'))))), less(sessions.`$start_timestamp`, toDateTime64('2024-01-01 14:00:05.000000', 6, 'UTC')), greater(sessions.`$start_timestamp`, toDateTime64('2024-01-01 00:00:00.000000', 6, 'UTC')))
+ ORDER BY sessions.session_id 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/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.new_events_schema.ambr b/posthog/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.new_events_schema.ambr
new file mode 100644
index 000000000000..c866b18328b0
--- /dev/null
+++ b/posthog/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.new_events_schema.ambr
@@ -0,0 +1,519 @@
+# serializer version: 1
+# name: TestSessionsTimelineQueryRunner.test_before_and_after[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 1001)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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: TestSessionsTimelineQueryRunner.test_before_and_after_defaults[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 1001)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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: TestSessionsTimelineQueryRunner.test_event_limit_and_has_more[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 3)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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: TestSessionsTimelineQueryRunner.test_formal_and_informal_sessions_global[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 1001)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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: TestSessionsTimelineQueryRunner.test_formal_session_with_recording[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 1001)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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: TestSessionsTimelineQueryRunner.test_formal_sessions_for_person[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), equals(if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id), 'd63e1ecf-f92f-1e50-71f9-501e16e9aebe'))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 1001)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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: TestSessionsTimelineQueryRunner.test_formal_sessions_global[new_events_schema]
+ '''
+ SELECT e.uuid AS uuid,
+ e.timestamp AS timestamp,
+ e.event AS event,
+ e.properties AS properties,
+ e.distinct_id AS distinct_id,
+ e.elements_chain AS elements_chain,
+ e.session_id AS formal_session_id,
+ first_value(e.uuid) OVER (PARTITION BY tuple(e.person_id, e.session_id_flip_index)
+ ORDER BY toInt64(e.timestamp) ASC RANGE BETWEEN 1800 PRECEDING AND CURRENT ROW) AS informal_session_uuid,
+ dateDiff('s', sre.start_time, sre.end_time) AS recording_duration_s
+ FROM
+ (SELECT uuid AS uuid,
+ person_id AS person_id,
+ timestamp AS timestamp,
+ event AS event,
+ properties AS properties,
+ distinct_id AS distinct_id,
+ elements_chain AS elements_chain,
+ session_id AS session_id,
+ sum(if(ifNull(equals(session_id, prev_session_id), isNull(session_id)
+ and isNull(prev_session_id)), 0, 1)) OVER (PARTITION BY person_id
+ ORDER BY timestamp ASC ROWS UNBOUNDED PRECEDING) AS session_id_flip_index
+ FROM
+ (SELECT event_source.uuid AS uuid,
+ if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id) AS person_id,
+ toTimeZone(event_source.timestamp, 'UTC') AS timestamp,
+ event_source.event AS 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(event_source.properties)))), ','), '}') AS properties,
+ event_source.distinct_id AS distinct_id,
+ event_source.elements_chain AS elements_chain,
+ event_source.`$session_id` AS session_id,
+ lagInFrame(event_source.`$session_id`, 1) OVER (PARTITION BY if(not(empty(event_source__override.distinct_id)), event_source__override.person_id, event_source.person_id)
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') ASC) AS prev_session_id
+ FROM events_json AS event_source
+ 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 event_source__override ON equals(event_source.distinct_id, event_source__override.distinct_id)
+ WHERE and(equals(event_source.team_id, 99999), greater(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), less(event_source.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
+ ORDER BY toTimeZone(event_source.timestamp, 'UTC') DESC
+ LIMIT 1001)) AS e
+ LEFT JOIN
+ (SELECT session_replay_events.start_time AS start_time,
+ session_replay_events.end_time AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM
+ (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,
+ max(toTimeZone(session_replay_events.max_last_timestamp, 'UTC')) AS end_time,
+ session_replay_events.session_id AS session_id
+ FROM session_replay_events
+ WHERE equals(session_replay_events.team_id, 99999)
+ GROUP BY session_replay_events.session_id) AS session_replay_events) AS sre ON equals(e.session_id, sre.session_id)
+ ORDER BY e.timestamp DESC
+ 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/models/test/__snapshots__/test_async_deletion_model.ambr b/posthog/models/test/__snapshots__/test_async_deletion_model.ambr
index c7113d7e6723..b348652c3814 100644
--- a/posthog/models/test/__snapshots__/test_async_deletion_model.ambr
+++ b/posthog/models/test/__snapshots__/test_async_deletion_model.ambr
@@ -31,16 +31,6 @@
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
'''
@@ -61,16 +51,6 @@
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
'''
@@ -93,17 +73,6 @@
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
'''
@@ -126,17 +95,6 @@
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
'''
@@ -153,14 +111,6 @@
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
'''
@@ -177,11 +127,3 @@
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/test/__snapshots__/test_async_deletion_model.new_events_schema.ambr b/posthog/models/test/__snapshots__/test_async_deletion_model.new_events_schema.ambr
new file mode 100644
index 000000000000..761d4cd3d9a0
--- /dev/null
+++ b/posthog/models/test/__snapshots__/test_async_deletion_model.new_events_schema.ambr
@@ -0,0 +1,59 @@
+# serializer version: 1
+# 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[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[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[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[new_events_schema]
+ '''
+
+ SELECT DISTINCT team_id
+ FROM events_json
+ 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.ambr
index be2a581ca0d8..1a0eae289a2d 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,48 +66,6 @@
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`,
@@ -309,7 +267,32 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit[new_events_schema.1]
+# 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
'''
SELECT breakdown_value AS `context.columns.breakdown_value`,
tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,
@@ -318,10 +301,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,
- events.properties.`$browser` AS breakdown_value,
+ 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_json AS events
+ 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
@@ -351,33 +334,16 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit[new_events_schema.2]
+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_
'''
- 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`,
+ 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`,
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)
+ 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')))
GROUP BY `context.columns.breakdown_value`
- ORDER BY `context.columns.visitors` DESC,
- `context.columns.views` DESC,
- `context.columns.breakdown_value` ASC
+ ORDER BY `context.columns.visitors` DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
max_execution_time=60,
@@ -393,7 +359,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_boundary_behavior_explicit[new_events_schema]
+# 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`,
@@ -402,10 +368,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,
- events.properties.`$browser` AS breakdown_value,
+ 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_json AS events
+ 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
@@ -413,7 +379,7 @@
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))
+ 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`
@@ -435,14 +401,14 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_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-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`,
+ 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-15 08:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 07: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` DESC
LIMIT 101
@@ -460,7 +426,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_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`,
@@ -480,7 +446,7 @@
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, '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))
+ 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`
@@ -502,7 +468,32 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_00_Pacific_UTC_08_00_[new_events_schema]
+# 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
'''
SELECT breakdown_value AS `context.columns.breakdown_value`,
tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,
@@ -511,10 +502,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,
- events.properties.`$browser` AS breakdown_value,
+ 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_json AS events
+ 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
@@ -522,7 +513,7 @@
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, '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))
+ 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`
@@ -544,14 +535,14 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_
+# 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-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`,
+ 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-15 05:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-17 04: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-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
@@ -569,7 +560,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_.1
+# 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`,
@@ -589,7 +580,7 @@
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, '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, '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`
@@ -611,7 +602,32 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_01_New_York_UTC_05_00_[new_events_schema]
+# 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`,
@@ -620,10 +636,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,
- events.properties.`$browser` AS breakdown_value,
+ 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_json AS events
+ 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
@@ -631,7 +647,7 @@
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, '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, '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`
@@ -653,14 +669,14 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_
+# 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-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-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-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-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
@@ -678,7 +694,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_.1
+# 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`,
@@ -698,7 +714,7 @@
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, '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, '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`
@@ -720,7 +736,32 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_02_Sao_Paulo_UTC_03_00_[new_events_schema]
+# 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`,
@@ -729,10 +770,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,
- events.properties.`$browser` AS breakdown_value,
+ 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_json AS events
+ 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
@@ -740,7 +781,7 @@
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, '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, '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`
@@ -762,14 +803,14 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_
+# 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-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`,
+ 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-15 00:00:00.000000', 6, 'UTC')), lessOrEquals(web_pre_aggregated_stats.period_bucket, toDateTime64('2024-01-16 23: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-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
@@ -787,7 +828,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_.1
+# 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`,
@@ -807,7 +848,7 @@
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))
+ 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`
@@ -829,598 +870,11 @@
use_hive_partitioning=0
'''
# ---
-# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_03_UTC_UTC_00_00_[new_events_schema]
+# name: TestTimezonePreAggregatedIntegration.test_timezone_hourly_bucketing_09_Sydney_UTC_11_00_
'''
- 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, '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`,
+ 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')))
@@ -1483,48 +937,6 @@
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`,
@@ -1592,45 +1004,3 @@
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/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.new_events_schema.ambr b/posthog/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.new_events_schema.ambr
new file mode 100644
index 000000000000..5297a2029ce6
--- /dev/null
+++ b/posthog/models/web_preaggregated/__snapshots__/test_web_pre_aggregated_timezones.new_events_schema.ambr
@@ -0,0 +1,631 @@
+# serializer version: 1
+# 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[new_events_schema.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,
+ 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, '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`
+ 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[new_events_schema.2]
+ '''
+ 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_boundary_behavior_explicit[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, '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_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`,
+ 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, '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`
+ 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_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`,
+ 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, '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`
+ 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_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`,
+ 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, '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`
+ 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_03_UTC_UTC_00_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, '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_[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_[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_[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_[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_[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_[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_[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.ambr
index 23162d1f9e98..12ae4e8167e9 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,54 +47,6 @@
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,
@@ -143,54 +95,6 @@
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,
@@ -241,56 +145,6 @@
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,
@@ -341,56 +195,6 @@
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,
@@ -441,7 +245,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_2_sessions_1_and_2_match_target_flag_is_set[new_events_schema]
+# 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)`,
@@ -465,14 +269,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_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']), 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)))
+ 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,
@@ -491,7 +293,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_two_is_not_event_properties
'''
SELECT s.session_id AS session_id,
any(s.team_id) AS `any(s.team_id)`,
@@ -518,7 +320,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_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')))
+ 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
@@ -539,7 +341,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_flags_3_sessions_3_and_4_match_target_flag_is_not_set[new_events_schema]
+# 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)`,
@@ -564,10 +366,10 @@
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`
+ (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_id
HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))
@@ -587,7 +389,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_two_is_not_event_properties
+# 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 +416,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_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')))
+ 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 +437,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_0.test_can_filter_for_two_is_not_event_properties[new_events_schema]
+# 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)`,
@@ -659,12 +461,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_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)))
+ 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,
@@ -683,7 +487,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_contain_event_properties
+# 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)`,
@@ -707,12 +511,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_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')), 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)))
+ 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,
@@ -731,7 +537,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_contain_event_properties[new_events_schema]
+# 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)`,
@@ -755,12 +561,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_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)))
+ 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,
@@ -779,7 +587,7 @@
use_hive_partitioning=0
'''
# ---
-# name: TestSessionRecordingsListByTopLevelEventProperty_1.test_can_filter_for_does_not_match_regex_event_properties
+# 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)`,
@@ -806,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_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')))
+ 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
@@ -827,451 +635,7 @@
use_hive_partitioning=0
'''
# ---
-# 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)`,
- 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_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
+# 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)`,
@@ -1319,51 +683,3 @@
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_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_recording_list_by_top_level_event_property.new_events_schema.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_by_top_level_event_property.new_events_schema.ambr
new file mode 100644
index 000000000000..006e9a047464
--- /dev/null
+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_by_top_level_event_property.new_events_schema.ambr
@@ -0,0 +1,685 @@
+# serializer version: 1
+# 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[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[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[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[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']), 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_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)`,
+ 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_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)`,
+ 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_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_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_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)`,
+ 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_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[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[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[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[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_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_recording_list_from_query.new_events_schema.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_from_query.new_events_schema.ambr
new file mode 100644
index 000000000000..ee30e924a351
--- /dev/null
+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_from_query.new_events_schema.ambr
@@ -0,0 +1,8462 @@
+# serializer version: 1
+# 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[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[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[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[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[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')), 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_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: 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)`,
+ 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')), 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_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: 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)`,
+ 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')), 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_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: 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)`,
+ 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')), 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_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: 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)`,
+ 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, 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_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: 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)`,
+ 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: 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)`,
+ 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, 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_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: 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)`,
+ 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: 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)`,
+ 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')), 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_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: 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)`,
+ 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')), 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_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: 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)`,
+ 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')), 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_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: 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)`,
+ 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')), 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_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: 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)`,
+ 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
+ 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('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: 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)`,
+ 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
+ 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('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: 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)`,
+ 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
+ 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('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: 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)`,
+ 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
+ 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('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: 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)`,
+ 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: 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)`,
+ 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: 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)`,
+ 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: 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)`,
+ 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: 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)`,
+ 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: 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)`,
+ 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: 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)`,
+ 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: 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)`,
+ 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_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_0.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_0.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_0.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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_0.test_event_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('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[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_has_ttl_applied_too[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_active_sessions[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, '$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), greater(active_seconds, 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_event_filter_with_active_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), 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), 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_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)`,
+ 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
+ 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_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_group_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('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
+ 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_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_group_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
+ 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_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[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[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[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[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[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[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_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[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_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[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_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[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_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[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_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[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[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[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[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[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[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[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[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_event_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('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_1.test_event_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('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_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)`,
+ 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_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)`,
+ 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), greater(active_seconds, 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_event_filter_with_active_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), 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), 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_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)`,
+ 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
+ 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_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_group_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('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
+ 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_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_group_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
+ 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_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[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_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)`,
+ 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_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)`,
+ 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_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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_1.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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_1.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_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)`,
+ 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_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)`,
+ 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_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)`,
+ 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_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_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)`,
+ 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_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_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)`,
+ 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_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_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)`,
+ 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_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_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)`,
+ 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_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_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)`,
+ 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
+ '''
+# ---
diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.new_events_schema.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.new_events_schema.ambr
new file mode 100644
index 000000000000..4f937ec03edc
--- /dev/null
+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recording_list_operands_queries.new_events_schema.ambr
@@ -0,0 +1,296 @@
+# serializer version: 1
+# 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[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[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[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[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.new_events_schema.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_cohort.new_events_schema.ambr
new file mode 100644
index 000000000000..10d39c7f592c
--- /dev/null
+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_cohort.new_events_schema.ambr
@@ -0,0 +1,268 @@
+# serializer version: 1
+# 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_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[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
+ '''
+# ---
diff --git a/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.new_events_schema.ambr b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.new_events_schema.ambr
new file mode 100644
index 000000000000..aa188039fbef
--- /dev/null
+++ b/posthog/session_recordings/queries/test/listing_recordings/__snapshots__/test_session_recordings_list_by_group_properties.new_events_schema.ambr
@@ -0,0 +1,331 @@
+# serializer version: 1
+# 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_stop_surveys_reached_target.ambr b/posthog/tasks/test/__snapshots__/test_stop_surveys_reached_target.ambr
index c8d3a8931650..4faa972ec375 100644
--- a/posthog/tasks/test/__snapshots__/test_stop_surveys_reached_target.ambr
+++ b/posthog/tasks/test/__snapshots__/test_stop_surveys_reached_target.ambr
@@ -41,45 +41,3 @@
use_hive_partitioning=0
'''
# ---
-# name: TestStopSurveysReachedTarget.test_stop_surveys_with_enough_responses[new_events_schema.1]
- '''
- SELECT events.properties.`$survey_id` AS survey_id,
- count(DISTINCT if(ifNull(notEquals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), ''), ''), 1), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), toString(events.uuid))) AS unique_responses
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'survey sent'), greaterOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), in(events.properties.`$survey_id`, ['00000000-0000-0000-0000-000000000003']))
- GROUP BY survey_id
- LIMIT 1 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: TestStopSurveysReachedTarget.test_stop_surveys_with_enough_responses[new_events_schema]
- '''
- SELECT events.properties.`$survey_id` AS survey_id,
- count(DISTINCT if(ifNull(notEquals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), ''), ''), 1), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), toString(events.uuid))) AS unique_responses
- FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'survey sent'), greaterOrEquals(events.timestamp, toDateTime64('2021-12-29 20:00:00.000000', 6, 'UTC')), in(events.properties.`$survey_id`, ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']))
- GROUP BY survey_id
- LIMIT 2 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_stop_surveys_reached_target.new_events_schema.ambr b/posthog/tasks/test/__snapshots__/test_stop_surveys_reached_target.new_events_schema.ambr
new file mode 100644
index 000000000000..10178e35b9ce
--- /dev/null
+++ b/posthog/tasks/test/__snapshots__/test_stop_surveys_reached_target.new_events_schema.ambr
@@ -0,0 +1,43 @@
+# serializer version: 1
+# name: TestStopSurveysReachedTarget.test_stop_surveys_with_enough_responses[new_events_schema.1]
+ '''
+ SELECT events.properties.`$survey_id` AS survey_id,
+ count(DISTINCT if(ifNull(notEquals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), ''), ''), 1), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), toString(events.uuid))) AS unique_responses
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'survey sent'), greaterOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), in(events.properties.`$survey_id`, ['00000000-0000-0000-0000-000000000003']))
+ GROUP BY survey_id
+ LIMIT 1 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: TestStopSurveysReachedTarget.test_stop_surveys_with_enough_responses[new_events_schema]
+ '''
+ SELECT events.properties.`$survey_id` AS survey_id,
+ count(DISTINCT if(ifNull(notEquals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), ''), ''), 1), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(events.properties.`$survey_submission_id`), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Array'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Map'), startsWith(dynamicType(events.properties.`$survey_submission_id`), 'Tuple')), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))), toString(events.uuid))) AS unique_responses
+ FROM events_json AS events
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'survey sent'), greaterOrEquals(events.timestamp, toDateTime64('2021-12-29 20:00:00.000000', 6, 'UTC')), in(events.properties.`$survey_id`, ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']))
+ GROUP BY survey_id
+ LIMIT 2 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.new_events_schema.ambr b/posthog/tasks/test/__snapshots__/test_usage_report.new_events_schema.ambr
new file mode 100644
index 000000000000..ac88b2ea6bec
--- /dev/null
+++ b/posthog/tasks/test/__snapshots__/test_usage_report.new_events_schema.ambr
@@ -0,0 +1,1124 @@
+# serializer version: 1
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.10]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 20:00:00'
+ AND timestamp < '2022-01-10 22:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.11]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 22:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.12]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 02:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.13]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 02:00:00'
+ AND timestamp < '2022-01-10 04:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.14]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 04:00:00'
+ AND timestamp < '2022-01-10 06:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.15]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 06:00:00'
+ AND timestamp < '2022-01-10 08:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.16]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 08:00:00'
+ AND timestamp < '2022-01-10 10:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.17]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 10:00:00'
+ AND timestamp < '2022-01-10 12:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.18]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 12:00:00'
+ AND timestamp < '2022-01-10 14:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.19]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 14:00:00'
+ AND timestamp < '2022-01-10 16:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.1]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 02:00:00'
+ AND timestamp < '2022-01-10 04:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.20]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 16:00:00'
+ AND timestamp < '2022-01-10 18:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.21]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 18:00:00'
+ AND timestamp < '2022-01-10 20:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.22]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 20:00:00'
+ AND timestamp < '2022-01-10 22:00:00'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.23]
+ '''
+
+ SELECT team_id,
+ replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') AS ai_lib,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 22:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ AND ifNull(properties.`$lib`, '') IN ('posthog-node')
+ AND startsWith(event, '$ai_')
+ WHERE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$ai_lib`) != '{}', toJSONString(properties.^`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'Array')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Map')
+ OR startsWith(dynamicType(properties.`$ai_lib`), 'Tuple'), toJSONString(properties.`$ai_lib`), if(startsWith(dynamicType(properties.`$ai_lib`), 'DateTime'), replaceOne(toString(properties.`$ai_lib`), ' ', 'T'), toString(properties.`$ai_lib`)))), ''), '^"|"$', '') IN ('posthog-openclaw',
+ '@posthog/pi',
+ 'posthog-ai')
+ GROUP BY team_id,
+ ai_lib
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.24]
+ '''
+
+ SELECT team_id,
+ multiIf(ifNull(properties.`$lib`, '') = 'web', 'web', ifNull(properties.`$lib`, '') = 'js', 'web_lite', ifNull(properties.`$lib`, '') = 'posthog-node', 'node', ifNull(properties.`$lib`, '') = 'posthog-edge', 'node', ifNull(properties.`$lib`, '') = 'posthog-android', 'android', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios', ifNull(properties.`$lib`, '') = 'posthog-go', 'go', ifNull(properties.`$lib`, '') = 'posthog-java', 'java', ifNull(properties.`$lib`, '') = 'posthog-server', 'java', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby', ifNull(properties.`$lib`, '') = 'posthog-python', 'python', 'unknown') AS library,
+ count(1) as total
+ FROM events_json
+ WHERE event = '$exception'
+ AND timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ GROUP BY team_id,
+ library
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.25]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 02:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.26]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 02:00:00'
+ AND timestamp < '2022-01-10 04:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.27]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 04:00:00'
+ AND timestamp < '2022-01-10 06:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.28]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 06:00:00'
+ AND timestamp < '2022-01-10 08:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.29]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 08:00:00'
+ AND timestamp < '2022-01-10 10:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.2]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 04:00:00'
+ AND timestamp < '2022-01-10 06:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.30]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 10:00:00'
+ AND timestamp < '2022-01-10 12:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.31]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 12:00:00'
+ AND timestamp < '2022-01-10 14:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.32]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 14:00:00'
+ AND timestamp < '2022-01-10 16:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.33]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 16:00:00'
+ AND timestamp < '2022-01-10 18:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.34]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 18:00:00'
+ AND timestamp < '2022-01-10 20:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.35]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 20:00:00'
+ AND timestamp < '2022-01-10 22:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.36]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 22:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.37]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 02:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.38]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 02:00:00'
+ AND timestamp < '2022-01-10 04:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.39]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 04:00:00'
+ AND timestamp < '2022-01-10 06:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.3]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 06:00:00'
+ AND timestamp < '2022-01-10 08:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.40]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 06:00:00'
+ AND timestamp < '2022-01-10 08:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.41]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 08:00:00'
+ AND timestamp < '2022-01-10 10:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.42]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 10:00:00'
+ AND timestamp < '2022-01-10 12:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.43]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 12:00:00'
+ AND timestamp < '2022-01-10 14:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.44]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 14:00:00'
+ AND timestamp < '2022-01-10 16:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.45]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 16:00:00'
+ AND timestamp < '2022-01-10 18:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.46]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 18:00:00'
+ AND timestamp < '2022-01-10 20:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.47]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 20:00:00'
+ AND timestamp < '2022-01-10 22:00:00'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.48]
+ '''
+
+ SELECT team_id,
+ count(distinct toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 22:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ 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
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.49]
+ '''
+
+ SELECT team_id,
+ count(1) as count
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ AND ($group_0 != ''
+ OR $group_1 != ''
+ OR $group_2 != ''
+ OR $group_3 != ''
+ OR $group_4 != '')
+ GROUP BY team_id
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.4]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 08:00:00'
+ AND timestamp < '2022-01-10 10:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.50]
+ '''
+
+ SELECT distinct_id as team,
+ sum(toInt64OrZero(replaceRegexpAll(ifNull(if(toJSONString(properties.^count) != '{}', toJSONString(properties.^count), if(startsWith(dynamicType(properties.count), 'Array')
+ OR startsWith(dynamicType(properties.count), 'Map')
+ OR startsWith(dynamicType(properties.count), 'Tuple'), toJSONString(properties.count), if(startsWith(dynamicType(properties.count), 'DateTime'), replaceOne(toString(properties.count), ' ', 'T'), toString(properties.count)))), ''), '^"|"$', ''))) as sum
+ FROM events_json
+ WHERE team_id = 99999
+ AND event='decide usage'
+ AND timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ AND has(['correct'], replaceRegexpAll(ifNull(if(toJSONString(properties.^token) != '{}', toJSONString(properties.^token), if(startsWith(dynamicType(properties.token), 'Array')
+ OR startsWith(dynamicType(properties.token), 'Map')
+ OR startsWith(dynamicType(properties.token), 'Tuple'), toJSONString(properties.token), if(startsWith(dynamicType(properties.token), 'DateTime'), replaceOne(toString(properties.token), ' ', 'T'), toString(properties.token)))), ''), '^"|"$', ''))
+ GROUP BY team
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.51]
+ '''
+
+ SELECT distinct_id as team,
+ sum(toInt64OrZero(replaceRegexpAll(ifNull(if(toJSONString(properties.^count) != '{}', toJSONString(properties.^count), if(startsWith(dynamicType(properties.count), 'Array')
+ OR startsWith(dynamicType(properties.count), 'Map')
+ OR startsWith(dynamicType(properties.count), 'Tuple'), toJSONString(properties.count), if(startsWith(dynamicType(properties.count), 'DateTime'), replaceOne(toString(properties.count), ' ', 'T'), toString(properties.count)))), ''), '^"|"$', ''))) as sum
+ FROM events_json
+ WHERE team_id = 99999
+ AND event='local evaluation usage'
+ AND timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ AND has(['correct'], replaceRegexpAll(ifNull(if(toJSONString(properties.^token) != '{}', toJSONString(properties.^token), if(startsWith(dynamicType(properties.token), 'Array')
+ OR startsWith(dynamicType(properties.token), 'Map')
+ OR startsWith(dynamicType(properties.token), 'Tuple'), toJSONString(properties.token), if(startsWith(dynamicType(properties.token), 'DateTime'), replaceOne(toString(properties.token), ' ', 'T'), toString(properties.token)))), ''), '^"|"$', ''))
+ GROUP BY team
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.52]
+ '''
+
+ SELECT team_id,
+ COUNT() as count
+ FROM events_json
+ WHERE event = 'survey sent'
+ AND timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ AND uuid IN
+ (SELECT argMax(uuid, timestamp)
+ FROM events_json
+ WHERE timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 23:59:59'
+ AND event = 'survey sent'
+ GROUP BY team_id,
+ ifNull(properties.`$survey_id`, ''),
+ CASE
+ WHEN COALESCE(replaceRegexpAll(ifNull(if(toJSONString(properties.^`$survey_submission_id`) != '{}', toJSONString(properties.^`$survey_submission_id`), if(startsWith(dynamicType(properties.`$survey_submission_id`), 'Array')
+ OR startsWith(dynamicType(properties.`$survey_submission_id`), 'Map')
+ OR startsWith(dynamicType(properties.`$survey_submission_id`), 'Tuple'), toJSONString(properties.`$survey_submission_id`), if(startsWith(dynamicType(properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(properties.`$survey_submission_id`), ' ', 'T'), toString(properties.`$survey_submission_id`)))), ''), '^"|"$', ''), '') = '' THEN toString(uuid)
+ ELSE replaceRegexpAll(ifNull(if(toJSONString(properties.^`$survey_submission_id`) != '{}', toJSONString(properties.^`$survey_submission_id`), if(startsWith(dynamicType(properties.`$survey_submission_id`), 'Array')
+ OR startsWith(dynamicType(properties.`$survey_submission_id`), 'Map')
+ OR startsWith(dynamicType(properties.`$survey_submission_id`), 'Tuple'), toJSONString(properties.`$survey_submission_id`), if(startsWith(dynamicType(properties.`$survey_submission_id`), 'DateTime'), replaceOne(toString(properties.`$survey_submission_id`), ' ', 'T'), toString(properties.`$survey_submission_id`)))), ''), '^"|"$', '')
+ END)
+ GROUP BY team_id
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.53]
+ '''
+
+ SELECT team_id,
+ COUNT() - uniqExactIf(request_id, verified
+ AND NOT relay
+ AND request_id != '') AS count,
+ max(relay) AS has_verified_relay
+ FROM
+ (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,
+ 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,
+ 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 relay
+ FROM events_json
+ WHERE 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'
+ AND timestamp < '2022-01-10 23:59:59')
+ GROUP BY team_id
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.54]
+ '''
+
+ SELECT team_id,
+ COUNT() - uniqExactIf(request_id, verified
+ AND request_id != '') as count
+ FROM
+ (SELECT team_id,
+ JSONExtractBool(toJSONString(properties), '$ai_gateway_verified') as verified,
+ if(verified, JSONExtractString(toJSONString(properties), '$ai_gateway_request_id'), '') as request_id
+ FROM events_json
+ WHERE 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'
+ AND timestamp < '2022-01-10 23:59:59')
+ GROUP BY team_id
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.5]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 10:00:00'
+ AND timestamp < '2022-01-10 12:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.6]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 12:00:00'
+ AND timestamp < '2022-01-10 14:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.7]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 14:00:00'
+ AND timestamp < '2022-01-10 16:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.8]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 16:00:00'
+ AND timestamp < '2022-01-10 18:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema.9]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 18:00:00'
+ AND timestamp < '2022-01-10 20:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
+# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests[new_events_schema]
+ '''
+
+ SELECT team_id,
+ multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', ifNull(properties.`$lib`, '') = 'web', 'web_events', ifNull(properties.`$lib`, '') = 'js', 'web_lite_events', ifNull(properties.`$lib`, '') = 'posthog-node', 'node_events', ifNull(properties.`$lib`, '') = 'posthog-edge', 'edge_events', ifNull(properties.`$lib`, '') = 'posthog-convex', 'convex_events', ifNull(properties.`$lib`, '') = 'posthog-android', 'android_events', ifNull(properties.`$lib`, '') = 'posthog-flutter', 'flutter_events', ifNull(properties.`$lib`, '') = 'posthog-ios', 'ios_events', ifNull(properties.`$lib`, '') = 'posthog-go', 'go_events', ifNull(properties.`$lib`, '') = 'posthog-java', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-server', 'java_events', ifNull(properties.`$lib`, '') = 'posthog-react-native', 'react_native_events', ifNull(properties.`$lib`, '') = 'posthog-ruby', 'ruby_events', ifNull(properties.`$lib`, '') = 'posthog-python', 'python_events', ifNull(properties.`$lib`, '') = 'posthog-php', 'php_events', ifNull(properties.`$lib`, '') = 'posthog-dotnet', 'dotnet_events', ifNull(properties.`$lib`, '') = 'posthog-elixir', 'elixir_events', ifNull(properties.`$lib`, '') = 'posthog-unity', 'unity_events', ifNull(properties.`$lib`, '') = 'posthog-rs', 'rust_events', 'other') AS metric,
+ count(1) as count
+ FROM events_json PREWHERE timestamp >= '2022-01-10 00:00:00'
+ AND timestamp < '2022-01-10 02:00:00'
+ WHERE (event LIKE 'helicone%'
+ OR event LIKE 'langfuse%'
+ OR event LIKE 'keywords_ai%'
+ OR event LIKE 'traceloop%'
+ OR ifNull(properties.`$lib`, '') IN ('web',
+ 'js',
+ 'posthog-node',
+ 'posthog-edge',
+ 'posthog-convex',
+ 'posthog-android',
+ 'posthog-flutter',
+ 'posthog-ios',
+ 'posthog-go',
+ 'posthog-java',
+ 'posthog-server',
+ 'posthog-react-native',
+ 'posthog-ruby',
+ 'posthog-python',
+ 'posthog-php',
+ 'posthog-dotnet',
+ 'posthog-elixir',
+ 'posthog-unity',
+ 'posthog-rs'))
+ GROUP BY team_id,
+ metric
+ '''
+# ---
diff --git a/posthog/test/base.py b/posthog/test/base.py
index 78c260179688..4163e147a7fe 100644
--- a/posthog/test/base.py
+++ b/posthog/test/base.py
@@ -1459,6 +1459,21 @@ def _format_sql_for_snapshot(query: str) -> str:
return formatted
+class NewEventsSchemaSnapshotExtension(AmberSnapshotExtension):
+ """Amber extension that writes new-events-schema snapshots to `<test_file>.new_events_schema.ambr`.
+
+ These snapshots only get written when CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA is on
+ (the label-gated CI legs). Kept in the shared `.ambr` file, a legacy-schema
+ `--snapshot-update` run deletes them as unused: syrupy resolves both
+ `test_x[new_events_schema]` and `test_x` to the same owning test, so a run of the
+ other schema mode claims the name but never writes it. A snapshot file whose name
+ matches no test file is skipped by syrupy's unused-snapshot pass entirely, which
+ keeps each schema mode's snapshots safe from the other mode's update runs.
+ """
+
+ _file_extension = "new_events_schema.ambr"
+
+
@pytest.mark.usefixtures("unittest_snapshot")
class QueryMatchingTest:
snapshot: Any
@@ -1477,7 +1492,7 @@ class QueryMatchingTest:
snapshot_index = getattr(self, "_new_events_schema_snapshot_index", 0)
self._new_events_schema_snapshot_index = snapshot_index + 1
snapshot_name = "new_events_schema" if snapshot_index == 0 else f"new_events_schema.{snapshot_index}"
- return self.snapshot(name=snapshot_name)
+ return self.snapshot(name=snapshot_name, extension_class=NewEventsSchemaSnapshotExtension)
# :NOTE: Update snapshots by passing --snapshot-update to bin/tests
def assertQueryMatchesSnapshot(self, query, params=None, replace_all_numbers=False):