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(hogql): read empty property values on events_json like legacy (#124459)

Sandy Spicer76612946ba86
diff --git a/docs/internal/ai-observability-judge-inputs.md b/docs/internal/ai-observability-judge-inputs.md
index 05fe43ebe3ba..f8bb56f21263 100644
--- a/docs/internal/ai-observability-judge-inputs.md
+++ b/docs/internal/ai-observability-judge-inputs.md
@@ -253,7 +253,7 @@ The editor updates the untouched Hog example when its category key changes, is r
Custom code is preserved.
The LLM judge returns `categories` and `reasoning`.
Single selection requires exactly one key; multiple selection accepts `[]` as an applicable result.
-Categorical events always set `$ai_evaluation_applicable`, because native JSON property reads treat empty arrays as absent.
+Categorical events always set `$ai_evaluation_applicable`.
`null` means N/A only when `allows_na` is enabled.
Unknown or duplicate keys are invalid results.
Invalid model responses and Hog results with unknown keys, duplicate keys, or the wrong number of selections skip the run without disabling the evaluation.
diff --git a/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr b/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr
index a3663e24a611..5fa6f37d8ea0 100644
--- a/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr
+++ b/posthog/api/test/__snapshots__/test_event.new_events_schema.ambr
@@ -2,10 +2,10 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop)))))) ASC
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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,
@@ -25,10 +25,10 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop)))))) ASC
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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,
@@ -48,10 +48,10 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop)))))) ASC
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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,
@@ -71,10 +71,10 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop)))))) ASC
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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,
@@ -94,10 +94,10 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop)))))) ASC
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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,
@@ -117,10 +117,10 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop)))))) ASC
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), 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,
@@ -161,9 +161,9 @@
# 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(nullIf(toString(events.properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(nullIf(toString(properties.random_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.random_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^random_prop), '{}'), toJSONString(events.properties.^random_prop), if(isNull(events.properties.random_prop), NULL, toJSONString(events.properties.random_prop))) AS `if(notEquals(toJSONString(properties.^random_prop), '{}'), toJSONString(properties.^random_prop), if(isNull(properties.random_prop), NULL, 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(nullIf(toString(events.properties.random_prop), '')), NULL, if(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.random_prop), '[]'), '{}'), toString(events.properties.random_prop))))))
+ 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(and(in(ascii(toString(events.properties.random_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.random_prop)), tuple(91, 123))), toJSONString(events.properties.random_prop), toString(events.properties.random_prop))))))
LIMIT 10 SETTINGS readonly=2,
max_execution_time=60,
allow_experimental_object_type=1,
@@ -183,9 +183,9 @@
# 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(nullIf(toString(events.properties.visible_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.visible_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^visible_prop), '{}'), toJSONString(properties.^visible_prop), if(isNull(nullIf(toString(properties.visible_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.visible_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^visible_prop), '{}'), toJSONString(events.properties.^visible_prop), if(isNull(events.properties.visible_prop), NULL, toJSONString(events.properties.visible_prop))) AS `if(notEquals(toJSONString(properties.^visible_prop), '{}'), toJSONString(properties.^visible_prop), if(isNull(properties.visible_prop), NULL, 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(nullIf(toString(events.properties.visible_prop), '')), NULL, if(and(in(ascii(toString(events.properties.visible_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.visible_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.visible_prop), '[]'), '{}'), toString(events.properties.visible_prop))))))
+ 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(and(in(ascii(toString(events.properties.visible_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.visible_prop)), tuple(91, 123))), toJSONString(events.properties.visible_prop), toString(events.properties.visible_prop))))))
LIMIT 10 SETTINGS readonly=2,
max_execution_time=60,
allow_experimental_object_type=1,
@@ -205,9 +205,9 @@
# 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(nullIf(toString(events.properties.test_prop), '')), NULL, nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'))) AS `if(notEquals(toJSONString(properties.^test_prop), '{}'), toJSONString(properties.^test_prop), if(isNull(nullIf(toString(properties.test_prop), '')), NULL, nullIf(nullIf(toJSONString(properties.test_prop), '[]'), '{}')))`
+ SELECT DISTINCT if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, toJSONString(events.properties.test_prop))) AS `if(notEquals(toJSONString(properties.^test_prop), '{}'), toJSONString(properties.^test_prop), if(isNull(properties.test_prop), NULL, 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(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ 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(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
LIMIT 10 SETTINGS readonly=2,
max_execution_time=60,
allow_experimental_object_type=1,
diff --git a/posthog/api/test/__snapshots__/test_query.new_events_schema.ambr b/posthog/api/test/__snapshots__/test_query.new_events_schema.ambr
index 0efd7d670c16..407ac417d0a0 100644
--- a/posthog/api/test/__snapshots__/test_query.new_events_schema.ambr
+++ b/posthog/api/test/__snapshots__/test_query.new_events_schema.ambr
@@ -4,9 +4,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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
@@ -37,16 +37,16 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.path), '')), NULL, if(and(in(ascii(toString(events.properties.path)), tuple(91, 123)), in(ascii(toJSONString(events.properties.path)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.path), '[]'), '{}'), toString(events.properties.path))))), '%/%'), 0), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^path), '{}'), toJSONString(events.properties.^path), if(isNull(events.properties.path), NULL, if(and(in(ascii(toString(events.properties.path)), tuple(91, 123)), in(ascii(toJSONString(events.properties.path)), tuple(91, 123))), 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(nullIf(toString(events.properties.path), '')), NULL, if(and(in(ascii(toString(events.properties.path)), tuple(91, 123)), in(ascii(toJSONString(events.properties.path)), tuple(91, 123))), nullIf(nullIf(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'))))
+ LIMIT 101)), and(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^path), '{}'), toJSONString(events.properties.^path), if(isNull(events.properties.path), NULL, if(and(in(ascii(toString(events.properties.path)), tuple(91, 123)), in(ascii(toJSONString(events.properties.path)), tuple(91, 123))), 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,
@@ -70,9 +70,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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
@@ -190,7 +190,7 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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
@@ -220,7 +220,7 @@
FROM
(SELECT events.event AS event,
events.distinct_id AS distinct_id,
- if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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
@@ -246,7 +246,7 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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
@@ -271,9 +271,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), toJSONString(properties.key), toString(properties.key)))))`
FROM events_json AS events
WHERE 0
ORDER BY events.event ASC
@@ -299,9 +299,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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
@@ -332,9 +332,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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
@@ -365,9 +365,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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
@@ -398,9 +398,9 @@
/* 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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
@@ -429,11 +429,11 @@
# 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ SELECT if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), toJSONString(events.properties.key), toString(events.properties.key))))
HAVING greater(count(), 1)
ORDER BY count() DESC
LIMIT 101
@@ -456,11 +456,11 @@
# 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ SELECT if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), toJSONString(events.properties.key), toString(events.properties.key))))
ORDER BY count() DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -584,7 +584,7 @@
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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(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')))
+ 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(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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
@@ -607,18 +607,18 @@
# 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) AS key,
+ SELECT if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key))))), '')) AS `concat(event, ' ', if(notEquals(toJSONString(properties.^key), '{}'), toJSONString(properties.^key), if(isNull(nullIf(toString(properties.key), '')), NULL, if(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(properties.key), '[]'), '{}'), toString(properties.key)))))`
+ concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(and(in(ascii(toString(properties.key)), tuple(91, 123)), in(ascii(toJSONString(properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) ASC
+ ORDER BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), 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(nullIf(toString(events.properties.key), '')), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.key), '[]'), '{}'), toString(events.properties.key)))) ASC
+ ORDER BY if(notEquals(toJSONString(events.properties.^key), '{}'), toJSONString(events.properties.^key), if(isNull(events.properties.key), NULL, if(and(in(ascii(toString(events.properties.key)), tuple(91, 123)), in(ascii(toJSONString(events.properties.key)), tuple(91, 123))), toJSONString(events.properties.key), toString(events.properties.key)))) ASC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
max_execution_time=60,
diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.new_events_schema.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.new_events_schema.ambr
index 7fe6e7b4a9c4..a3fb2bb843c0 100644
--- a/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.new_events_schema.ambr
+++ b/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.new_events_schema.ambr
@@ -4,410 +4,209 @@
SELECT groups.key AS key,
groups__revenue_analytics.revenue AS revenue,
groups__revenue_analytics.mrr AS mrr
- FROM (
- SELECT argMax(groups.group_key,
- toTimeZone(groups._timestamp,
- 'UTC')) AS groups___key,
- groups.group_type_index AS index,
- groups.group_key AS key
- FROM groups
- WHERE equals(groups.team_id,
- 99999)
- GROUP BY groups.group_type_index,
- groups.group_key) AS groups
- LEFT JOIN (
- SELECT 99999 AS team_id,
- coalesce(revenue_agg.group_key,
- mrr_agg.group_key) AS group_key,
- coalesce(revenue_agg.revenue,
- accurateCastOrNull(0,
- 'Decimal64(10)')) AS revenue,
- coalesce(mrr_agg.mrr,
- accurateCastOrNull(0,
- 'Decimal64(10)')) AS mrr
- FROM (
- SELECT arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key,
- sum(revenue_analytics_revenue_item.amount) AS revenue
- FROM (
- SELECT toString(events.uuid) AS id,
+ FROM
+ (SELECT argMax(groups.group_key, toTimeZone(groups._timestamp, 'UTC')) AS groups___key,
+ groups.group_type_index AS index,
+ groups.group_key AS key
+ FROM groups
+ WHERE equals(groups.team_id, 99999)
+ GROUP BY groups.group_type_index,
+ groups.group_key) AS groups
+ LEFT JOIN
+ (SELECT 99999 AS team_id,
+ coalesce(revenue_agg.group_key, mrr_agg.group_key) AS group_key,
+ coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue,
+ coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr
+ FROM
+ (SELECT arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key,
+ sum(revenue_analytics_revenue_item.amount) AS revenue
+ FROM
+ (SELECT toString(events.uuid) AS id,
toString(events.uuid) AS invoice_item_id,
+ 'revenue_analytics.events.purchase' AS source_label,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ timestamp AS created_at,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
+ NULL AS product_id,
+ toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
+ events.properties.`$group_0` AS group_0_key,
+ events.properties.`$group_1` AS group_1_key,
+ events.properties.`$group_2` AS group_2_key,
+ events.properties.`$group_3` AS group_3_key,
+ events.properties.`$group_4` AS group_4_key,
+ NULL AS invoice_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
+ toString(events.properties.`$session_id`) AS session_id,
+ events.event AS event_name,
+ NULL AS coupon,
+ coupon AS coupon_id,
+ 'USD' AS original_currency,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ in(original_currency,
+ ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
+ if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
+ divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount,
+ 'USD' AS currency,
+ if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ 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(equals(events.event, 'purchase'), 1, isNotNull(amount)))
+ ORDER BY timestamp DESC) AS revenue_analytics_revenue_item
+ WHERE notEmpty(group_key)
+ GROUP BY group_key) AS revenue_agg
+ FULL OUTER JOIN
+ (SELECT customer_to_group.group_key AS group_key,
+ sum(coalesce(mrr_by_customer.mrr, accurateCastOrNull(0, 'Decimal64(10)'))) AS mrr
+ FROM
+ (SELECT DISTINCT revenue_analytics_revenue_item.customer_id AS customer_id,
+ arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key
+ FROM
+ (SELECT toString(events.uuid) AS id,
+ toString(events.uuid) AS invoice_item_id,
+ 'revenue_analytics.events.purchase' AS source_label,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ timestamp AS created_at,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
+ NULL AS product_id,
+ toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
+ events.properties.`$group_0` AS group_0_key,
+ events.properties.`$group_1` AS group_1_key,
+ events.properties.`$group_2` AS group_2_key,
+ events.properties.`$group_3` AS group_3_key,
+ events.properties.`$group_4` AS group_4_key,
+ NULL AS invoice_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
+ toString(events.properties.`$session_id`) AS session_id,
+ events.event AS event_name,
+ NULL AS coupon,
+ coupon AS coupon_id,
+ 'USD' AS original_currency,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ in(original_currency,
+ ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
+ if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
+ divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount,
+ 'USD' AS currency,
+ if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ 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(equals(events.event, 'purchase'), 1, isNotNull(amount)))
+ ORDER BY timestamp DESC) AS revenue_analytics_revenue_item
+ WHERE notEmpty(group_key)) AS customer_to_group
+ LEFT JOIN
+ (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id,
+ sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr
+ FROM
+ (SELECT union.source_label AS source_label,
+ union.customer_id AS customer_id,
+ union.subscription_id AS subscription_id,
+ argMax(union.amount, union.timestamp) AS mrr
+ FROM
+ (SELECT revenue_item.source_label AS source_label,
+ revenue_item.customer_id AS customer_id,
+ revenue_item.subscription_id AS subscription_id,
+ toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp,
+ sum(revenue_item.amount) AS amount
+ FROM
+ (SELECT toString(events.uuid) AS id,
+ toString(events.uuid) AS invoice_item_id,
'revenue_analytics.events.purchase' AS source_label,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
- NULL AS product_id,
- toString(if(not(empty(events__override.distinct_id)), events__override.person_id,
- events.person_id)) AS customer_id,
- events.properties.`$group_0` AS group_0_key,
- events.properties.`$group_1` AS group_1_key,
- events.properties.`$group_2` AS group_2_key,
- events.properties.`$group_3` AS group_3_key,
- events.properties.`$group_4` AS group_4_key,
- NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
- toString(events.properties.`$session_id`) AS session_id,
- events.event AS event_name,
- NULL AS coupon,
- coupon AS coupon_id,
- 'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL,
- if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
- in(original_currency,
- ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
- if(enable_currency_aware_divider,
- accurateCastOrNull(1,
- 'Decimal64(10)'), accurateCastOrNull(100,
- 'Decimal64(10)')) AS currency_aware_divider,
- divideDecimal(original_amount,
- currency_aware_divider) AS currency_aware_amount,
- 'USD' AS currency,
- if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
- 'Decimal64(10)'), if(equals('USD',
- 'USD'), toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(0,
- 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(1,
- 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)))))) AS amount
- 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(equals(events.event,
- 'purchase'), 1,
- isNotNull(amount)))
- ORDER BY timestamp DESC) AS revenue_analytics_revenue_item
- WHERE notEmpty(group_key)
- GROUP BY group_key) AS revenue_agg
- FULL OUTER JOIN (
- SELECT customer_to_group.group_key AS group_key,
- sum(coalesce(mrr_by_customer.mrr,
- accurateCastOrNull(0,
- 'Decimal64(10)'))) AS mrr
- FROM (
- SELECT DISTINCT revenue_analytics_revenue_item.customer_id AS customer_id,
- arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key
- FROM (
- SELECT toString(events.uuid) AS id,
- toString(events.uuid) AS invoice_item_id,
+ toTimeZone(events.timestamp, 'UTC') AS timestamp,
+ timestamp AS created_at,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
+ NULL AS product_id,
+ toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
+ events.properties.`$group_0` AS group_0_key,
+ events.properties.`$group_1` AS group_1_key,
+ events.properties.`$group_2` AS group_2_key,
+ events.properties.`$group_3` AS group_3_key,
+ events.properties.`$group_4` AS group_4_key,
+ NULL AS invoice_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
+ toString(events.properties.`$session_id`) AS session_id,
+ events.event AS event_name,
+ NULL AS coupon,
+ coupon AS coupon_id,
+ 'USD' AS original_currency,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ in(original_currency,
+ ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
+ if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
+ divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount,
+ 'USD' AS currency,
+ if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ 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(equals(events.event, 'purchase'), 1, isNotNull(amount)))
+ ORDER BY timestamp DESC) AS revenue_item
+ WHERE and(revenue_item.is_recurring, isNotNull(revenue_item.subscription_id), ifNull(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), 0), ifNull(lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), 0))
+ GROUP BY revenue_item.source_label,
+ revenue_item.customer_id,
+ revenue_item.subscription_id, timestamp
+ ORDER BY timestamp DESC
+ UNION ALL SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label,
+ `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id,
+ `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id,
+ toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, 'UTC') AS timestamp,
+ accurateCastOrNull(0, 'Decimal64(10)') AS amount
+ FROM
+ (SELECT subscription_id AS id,
'revenue_analytics.events.purchase' AS source_label,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
- NULL AS product_id,
- toString(if(not(empty(events__override.distinct_id)), events__override.person_id,
- events.person_id)) AS customer_id,
- events.properties.`$group_0` AS group_0_key,
- events.properties.`$group_1` AS group_1_key,
- events.properties.`$group_2` AS group_2_key,
- events.properties.`$group_3` AS group_3_key,
- events.properties.`$group_4` AS group_4_key,
- NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
- toString(events.properties.`$session_id`) AS session_id,
- events.event AS event_name,
- NULL AS coupon,
- coupon AS coupon_id,
- 'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL,
- if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
- in(original_currency,
- ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
- if(enable_currency_aware_divider,
- accurateCastOrNull(1,
- 'Decimal64(10)'), accurateCastOrNull(100,
- 'Decimal64(10)')) AS currency_aware_divider,
- divideDecimal(original_amount,
- currency_aware_divider) AS currency_aware_amount,
- 'USD' AS currency,
- if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
- 'Decimal64(10)'), if(equals('USD',
- 'USD'), toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(0,
- 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(1,
- 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)))))) AS amount
- 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(equals(events.event,
- 'purchase'), 1,
- isNotNull(amount)))
- ORDER BY timestamp DESC) AS revenue_analytics_revenue_item
- WHERE notEmpty(group_key)) AS customer_to_group
- LEFT JOIN (
- SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id,
- sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr
- FROM (
- SELECT union.source_label AS source_label,
- union.customer_id AS customer_id,
- union.subscription_id AS subscription_id,
- argMax(union.amount,
- union.timestamp) AS mrr
- FROM (
- SELECT revenue_item.source_label AS source_label,
- revenue_item.customer_id AS customer_id,
- revenue_item.subscription_id AS subscription_id,
- toStartOfMonth(toTimeZone(revenue_item.timestamp,
- 'UTC')) AS timestamp,
- sum(revenue_item.amount) AS amount
- FROM (
- SELECT toString(events.uuid) AS id,
- toString(events.uuid) AS invoice_item_id,
- 'revenue_analytics.events.purchase' AS source_label,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
- NULL AS product_id,
- toString(if(not(empty(events__override.distinct_id)), events__override.person_id,
- events.person_id)) AS customer_id,
- events.properties.`$group_0` AS group_0_key,
- events.properties.`$group_1` AS group_1_key,
- events.properties.`$group_2` AS group_2_key,
- events.properties.`$group_3` AS group_3_key,
- events.properties.`$group_4` AS group_4_key,
- NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
- toString(events.properties.`$session_id`) AS session_id,
- events.event AS event_name,
- NULL AS coupon,
- coupon AS coupon_id,
- 'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL,
- if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
- in(original_currency,
- ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
- if(enable_currency_aware_divider,
- accurateCastOrNull(1,
- 'Decimal64(10)'), accurateCastOrNull(100,
- 'Decimal64(10)')) AS currency_aware_divider,
- divideDecimal(original_amount,
- currency_aware_divider) AS currency_aware_amount,
- 'USD' AS currency,
- if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
- 'Decimal64(10)'), if(equals('USD',
- 'USD'), toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(0,
- 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(1,
- 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)))))) AS amount
- 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(equals(events.event,
- 'purchase'), 1,
- isNotNull(amount)))
- ORDER BY timestamp DESC) AS revenue_item
- WHERE and(revenue_item.is_recurring,
- isNotNull(revenue_item.subscription_id), ifNull(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp',
- 6,
- 'UTC'), -60))), 0), ifNull(lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp',
- 6,
- 'UTC')), 0))
- GROUP BY revenue_item.source_label,
- revenue_item.customer_id,
- revenue_item.subscription_id, timestamp
- ORDER BY timestamp DESC
- UNION ALL
- SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label,
- `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id,
- `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id,
- toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at,
- 'UTC') AS timestamp,
- accurateCastOrNull(0,
- 'Decimal64(10)') AS amount
- FROM (
- SELECT subscription_id AS id,
- 'revenue_analytics.events.purchase' AS source_label,
- NULL AS plan_id,
- product_id AS product_id,
- toString(person_id) AS customer_id,
- NULL AS status,
- min_timestamp AS started_at,
- if(greater(max_timestamp_plus_dropoff_days,
- today()), NULL,
- max_timestamp_plus_dropoff_days) AS ended_at,
- NULL AS metadata
- FROM (
- SELECT if(not(empty(events__override.distinct_id)), events__override.person_id,
- events.person_id) AS person_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL,
- if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
- NULL AS product_id,
- min(toTimeZone(events.timestamp,
- 'UTC')) AS min_timestamp,
- max(toTimeZone(events.timestamp,
- 'UTC')) AS max_timestamp,
- addDays(max_timestamp,
- 45.0) AS max_timestamp_plus_dropoff_days
- 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(1,
- isNotNull(subscription_id)))
- GROUP BY subscription_id,
- person_id)
- ORDER BY started_at DESC) AS `revenue_analytics.events.purchase.subscription_events_revenue_view`
- WHERE and(ifNull(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp',
- 6,
- 'UTC'), -60))), 0), ifNull(lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp',
- 6,
- 'UTC')), 0))
- ORDER BY timestamp DESC) AS
- union
- GROUP BY source_label,
- customer_id,
- subscription_id
- ORDER BY customer_id ASC,
- subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view`
- GROUP BY customer_id) AS mrr_by_customer ON equals(customer_to_group.customer_id,
- mrr_by_customer.customer_id)
- GROUP BY group_key) AS mrr_agg ON equals(revenue_agg.group_key,
- mrr_agg.group_key)) AS groups__revenue_analytics ON equals(groups.groups___key,
- groups__revenue_analytics.group_key)
- WHERE equals(groups.key,
- 'lolol0:xxx')
+ NULL AS plan_id,
+ product_id AS product_id,
+ toString(person_id) AS customer_id,
+ NULL AS status,
+ min_timestamp AS started_at,
+ if(greater(max_timestamp_plus_dropoff_days, today()), NULL, max_timestamp_plus_dropoff_days) AS ended_at,
+ NULL AS metadata
+ FROM
+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
+ NULL AS product_id,
+ min(toTimeZone(events.timestamp, 'UTC')) AS min_timestamp,
+ max(toTimeZone(events.timestamp, 'UTC')) AS max_timestamp,
+ addDays(max_timestamp, 45.0) AS max_timestamp_plus_dropoff_days
+ 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(1, isNotNull(subscription_id)))
+ GROUP BY subscription_id,
+ person_id)
+ ORDER BY started_at DESC) AS `revenue_analytics.events.purchase.subscription_events_revenue_view`
+ WHERE and(ifNull(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), 0), ifNull(lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), 0))
+ ORDER BY timestamp DESC) AS
+ union
+ GROUP BY source_label,
+ customer_id,
+ subscription_id
+ ORDER BY customer_id ASC,
+ subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view`
+ GROUP BY customer_id) AS mrr_by_customer ON equals(customer_to_group.customer_id, mrr_by_customer.customer_id)
+ GROUP BY group_key) AS mrr_agg ON equals(revenue_agg.group_key, mrr_agg.group_key)) AS groups__revenue_analytics ON equals(groups.groups___key, groups__revenue_analytics.group_key)
+ WHERE equals(groups.key, 'lolol0:xxx')
LIMIT 100 SETTINGS format_csv_allow_double_quotes=1,
readonly=2,
max_execution_time=60,
@@ -467,7 +266,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -513,7 +312,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -566,7 +365,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -650,7 +449,7 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
NULL AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
@@ -659,13 +458,13 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -696,7 +495,7 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
NULL AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
@@ -705,13 +504,13 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -749,7 +548,7 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
NULL AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
@@ -758,13 +557,13 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -803,7 +602,7 @@
NULL AS metadata
FROM
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
NULL AS product_id,
min(toTimeZone(events.timestamp, 'UTC')) AS min_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS max_timestamp,
diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.new_events_schema.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.new_events_schema.ambr
index 61acd1550494..075ca898736a 100644
--- a/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.new_events_schema.ambr
+++ b/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.new_events_schema.ambr
@@ -88,7 +88,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -141,7 +141,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -293,7 +293,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -346,7 +346,7 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -478,7 +478,7 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
NULL AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
@@ -487,13 +487,13 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -531,7 +531,7 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id))))) AS is_recurring,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS is_recurring,
NULL AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
@@ -540,13 +540,13 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
in(original_currency,
['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
@@ -585,7 +585,7 @@
NULL AS metadata
FROM
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(nullIf(toString(events.properties.subscription_id), '')), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription_id), '[]'), '{}'), toString(events.properties.subscription_id)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, if(and(in(ascii(toString(events.properties.subscription_id)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription_id)), tuple(91, 123))), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))) AS subscription_id,
NULL AS product_id,
min(toTimeZone(events.timestamp, 'UTC')) AS min_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS max_timestamp,
@@ -663,7 +663,7 @@
LEFT JOIN (
SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'GBP' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'GBP' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
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
@@ -681,7 +681,7 @@
FROM (
SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'GBP' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'GBP' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
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
@@ -836,7 +836,7 @@
LEFT JOIN (
SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(events__pdi.person_id) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(events__pdi.person_id) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
FROM events_json AS events
INNER JOIN (
SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id
@@ -854,7 +854,7 @@
FROM (
SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(events__pdi.person_id) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(events__pdi.person_id) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
FROM events_json AS events
INNER JOIN (
SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id
@@ -1044,51 +1044,51 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL,
- if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
- in(original_currency,
- ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
- if(enable_currency_aware_divider,
- accurateCastOrNull(1,
- 'Decimal64(10)'), accurateCastOrNull(100,
- 'Decimal64(10)')) AS currency_aware_divider,
- divideDecimal(original_amount,
- currency_aware_divider) AS currency_aware_amount,
- 'USD' AS currency,
- if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
- 'Decimal64(10)'), if(equals('USD',
- 'USD'), toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(0,
- 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(1,
- 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)))))) AS amount
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL,
+ if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
+ 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ in(original_currency,
+ ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
+ if(enable_currency_aware_divider,
+ accurateCastOrNull(1,
+ 'Decimal64(10)'), accurateCastOrNull(100,
+ 'Decimal64(10)')) AS currency_aware_divider,
+ divideDecimal(original_amount,
+ currency_aware_divider) AS currency_aware_amount,
+ 'USD' AS currency,
+ if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
+ 'Decimal64(10)'), if(equals('USD',
+ 'USD'), toDecimal128(currency_aware_amount,
+ 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)), toDecimal64(0,
+ 10)) = 0,
+ toDecimal128(0,
+ 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
+ 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)), toDecimal64(0,
+ 10)) = 0,
+ toDecimal128(1,
+ 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)), toDecimal64(0,
+ 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)))))) AS amount
FROM events_json AS events
WHERE and(equals(events.team_id,
99999), and(equals(events.event,
@@ -1135,51 +1135,51 @@
NULL AS coupon,
coupon AS coupon_id,
'USD' AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL,
- if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
- in(original_currency,
- ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
- if(enable_currency_aware_divider,
- accurateCastOrNull(1,
- 'Decimal64(10)'), accurateCastOrNull(100,
- 'Decimal64(10)')) AS currency_aware_divider,
- divideDecimal(original_amount,
- currency_aware_divider) AS currency_aware_amount,
- 'USD' AS currency,
- if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
- 'Decimal64(10)'), if(equals('USD',
- 'USD'), toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(0,
- 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
- 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)) = 0,
- toDecimal128(1,
- 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)), toDecimal64(0,
- 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
- 'rate',
- 'USD',
- toDate(toTimeZone(events.timestamp,
- 'UTC')), toDecimal64(0,
- 10)))))) AS amount
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL,
+ if(and(in(ascii(toString(events.properties.revenue)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91,
+ 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ in(original_currency,
+ ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider,
+ if(enable_currency_aware_divider,
+ accurateCastOrNull(1,
+ 'Decimal64(10)'), accurateCastOrNull(100,
+ 'Decimal64(10)')) AS currency_aware_divider,
+ divideDecimal(original_amount,
+ currency_aware_divider) AS currency_aware_amount,
+ 'USD' AS currency,
+ if(isNull('USD'), accurateCastOrNull(currency_aware_amount,
+ 'Decimal64(10)'), if(equals('USD',
+ 'USD'), toDecimal128(currency_aware_amount,
+ 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)), toDecimal64(0,
+ 10)) = 0,
+ toDecimal128(0,
+ 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount,
+ 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)), toDecimal64(0,
+ 10)) = 0,
+ toDecimal128(1,
+ 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)), toDecimal64(0,
+ 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`,
+ 'rate',
+ 'USD',
+ toDate(toTimeZone(events.timestamp,
+ 'UTC')), toDecimal64(0,
+ 10)))))) AS amount
FROM events_json AS events
WHERE and(equals(events.team_id,
99999), and(equals(events.event,
@@ -1349,7 +1349,7 @@
LEFT JOIN (
SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
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
@@ -1367,7 +1367,7 @@
FROM (
SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
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
@@ -1484,7 +1484,7 @@
LEFT JOIN (
SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
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
@@ -1502,7 +1502,7 @@
FROM (
SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount
FROM (
- SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.properties.`$group_0` AS group_0_key, events.properties.`$group_1` AS group_1_key, events.properties.`$group_2` AS group_2_key, events.properties.`$group_3` AS group_3_key, events.properties.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.properties.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
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
diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.new_events_schema.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.new_events_schema.ambr
index b99026790faf..d878eccb0725 100644
--- a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.new_events_schema.ambr
+++ b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.new_events_schema.ambr
@@ -31,7 +31,7 @@
SELECT DISTINCT session_replay_events.session_id AS session_id
FROM session_replay_events
JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))) AS `properties___$current_url`,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))) AS `properties___$current_url`,
events.properties.`$session_id` AS `$session_id`
FROM events_json AS events PREWHERE greaterOrEquals(events.timestamp, toDateTime64(minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90)), 6, 'UTC'))
WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`)
@@ -60,7 +60,7 @@
WHERE and(equals(session_replay_events.team_id, 99999), globalIn(session_replay_events.session_id,
(SELECT events.properties.`$session_id` AS `$session_id`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%example.com%'), 0)))))
+ WHERE and(equals(events.team_id, 99999), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%example.com%'), 0)))))
ORDER BY session_replay_events.session_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -84,7 +84,7 @@
any(raw_session_replay_events__events.`properties___$current_url`) AS `any(events.properties.$current_url)`
FROM session_replay_events
JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))) AS `properties___$current_url`,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))) AS `properties___$current_url`,
events.properties.`$session_id` AS `$session_id`
FROM events_json AS events PREWHERE greaterOrEquals(events.timestamp, toDateTime64(minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90)), 6, 'UTC'))
WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`)
@@ -112,7 +112,7 @@
SELECT DISTINCT session_replay_events.session_id AS session_id
FROM session_replay_events
JOIN
- (SELECT if(notEquals(toJSONString(events.person_properties.^person_property), '{}'), toJSONString(events.person_properties.^person_property), if(isNull(nullIf(toString(events.person_properties.person_property), '')), NULL, if(and(in(ascii(toString(events.person_properties.person_property)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.person_property)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.person_property), '[]'), '{}'), toString(events.person_properties.person_property)))) AS poe___properties___person_property,
+ (SELECT if(notEquals(toJSONString(events.person_properties.^person_property), '{}'), toJSONString(events.person_properties.^person_property), if(isNull(events.person_properties.person_property), NULL, if(and(in(ascii(toString(events.person_properties.person_property)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.person_property)), tuple(91, 123))), toJSONString(events.person_properties.person_property), toString(events.person_properties.person_property)))) AS poe___properties___person_property,
events.properties.`$session_id` AS `$session_id`
FROM events_json AS events PREWHERE greaterOrEquals(events.timestamp, toDateTime64(minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90)), 6, 'UTC'))
WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`)
diff --git a/posthog/hogql/database/test/__snapshots__/test_database.new_events_schema.ambr b/posthog/hogql/database/test/__snapshots__/test_database.new_events_schema.ambr
index 51d39a8ce63e..1570276f88f7 100644
--- a/posthog/hogql/database/test/__snapshots__/test_database.new_events_schema.ambr
+++ b/posthog/hogql/database/test/__snapshots__/test_database.new_events_schema.ambr
@@ -9,7 +9,7 @@
SELECT groups.group_type_index AS index, groups.group_key AS key
FROM groups
WHERE equals(groups.team_id, 420)
- GROUP BY groups.group_type_index, groups.group_key) AS groups) AS events__some_field ON equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email)))), events__some_field.events__some_field___key)
+ GROUP BY groups.group_type_index, groups.group_key) AS groups) AS events__some_field ON equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email)))), events__some_field.events__some_field___key)
WHERE equals(events.team_id, 420)
LIMIT 50000
'''
@@ -24,7 +24,7 @@
SELECT groups.group_type_index AS index, groups.group_key AS key
FROM groups
WHERE equals(groups.team_id, 420)
- GROUP BY groups.group_type_index, groups.group_key) AS groups) AS events__some_field ON equals(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), events__some_field.events__some_field___key)
+ GROUP BY groups.group_type_index, groups.group_key) AS groups) AS events__some_field ON equals(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), events__some_field.events__some_field___key)
WHERE equals(events.team_id, 420)
LIMIT 50000
'''
diff --git a/posthog/hogql/printer/test/__snapshots__/test_printer.new_events_schema.ambr b/posthog/hogql/printer/test/__snapshots__/test_printer.new_events_schema.ambr
index ba9234a7ece4..b12987cf9c89 100644
--- a/posthog/hogql/printer/test/__snapshots__/test_printer.new_events_schema.ambr
+++ b/posthog/hogql/printer/test/__snapshots__/test_printer.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), ''), ''), 'foo'))
+ WHERE and(equals(events.team_id, 99999), equals(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), ''), 'foo'))
LIMIT 100 SETTINGS force_data_skipping_indices='bloom_filter_mat_test_prop',
readonly=2,
max_execution_time=60,
@@ -47,7 +47,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -69,7 +69,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -91,7 +91,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -113,7 +113,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -135,7 +135,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -157,7 +157,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -179,7 +179,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -201,7 +201,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -223,7 +223,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -245,7 +245,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -267,7 +267,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -289,7 +289,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -311,7 +311,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -333,7 +333,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -355,7 +355,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -377,7 +377,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -399,7 +399,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -421,7 +421,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -443,7 +443,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -465,7 +465,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -487,7 +487,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -509,7 +509,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -531,7 +531,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -553,7 +553,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -575,7 +575,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -597,7 +597,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -619,7 +619,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -641,7 +641,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -663,7 +663,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -685,7 +685,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -707,7 +707,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -729,7 +729,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -751,7 +751,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -773,7 +773,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -795,7 +795,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -817,7 +817,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -839,7 +839,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -861,7 +861,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -883,7 +883,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -905,7 +905,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -927,7 +927,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -949,7 +949,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -971,7 +971,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -993,7 +993,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1015,7 +1015,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1037,7 +1037,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1059,7 +1059,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1081,7 +1081,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1103,7 +1103,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1125,7 +1125,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1147,7 +1147,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1169,7 +1169,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1191,7 +1191,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1213,7 +1213,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1235,7 +1235,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%null%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%null%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1257,7 +1257,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1279,7 +1279,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1301,7 +1301,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1323,7 +1323,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), ''), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), ''), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1345,7 +1345,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '%@posthog.com'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1367,7 +1367,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1389,7 +1389,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1455,7 +1455,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1477,7 +1477,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1719,7 +1719,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1741,7 +1741,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1807,7 +1807,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1829,7 +1829,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2071,7 +2071,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2093,7 +2093,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2159,7 +2159,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2181,7 +2181,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2423,7 +2423,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2445,7 +2445,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2511,7 +2511,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2533,7 +2533,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2775,7 +2775,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2797,7 +2797,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2863,7 +2863,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2885,7 +2885,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('[email protected]', '')), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3127,7 +3127,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), ifNull(notIn(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), ifNull(notIn(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3149,7 +3149,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), in(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '[email protected]'))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), in(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '[email protected]'))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3171,7 +3171,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), ifNull(notIn(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '[email protected]'), 1))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), ifNull(notIn(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '[email protected]'), 1))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3193,7 +3193,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), in(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '[email protected]'))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), in(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '[email protected]'))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3215,7 +3215,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_bloom_events_test'), in(lower(if(notEquals(toJSONString(events.properties.^email), '{}'), toJSONString(events.properties.^email), if(isNull(nullIf(toString(events.properties.email), '')), NULL, if(and(in(ascii(toString(events.properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.email), '[]'), '{}'), toString(events.properties.email))))), ['[email protected]', '[email protected]']))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_bloom_events_test'), in(lower(if(notEquals(toJSONString(events.properties.^email), '{}'), toJSONString(events.properties.^email), if(isNull(events.properties.email), NULL, if(and(in(ascii(toString(events.properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.properties.email)), tuple(91, 123))), toJSONString(events.properties.email), toString(events.properties.email))))), ['[email protected]', '[email protected]']))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
allow_experimental_object_type=1,
@@ -3236,7 +3236,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_ngram_events_test'), in(lower(if(notEquals(toJSONString(events.properties.^email), '{}'), toJSONString(events.properties.^email), if(isNull(nullIf(toString(events.properties.email), '')), NULL, if(and(in(ascii(toString(events.properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.email), '[]'), '{}'), toString(events.properties.email))))), ['[email protected]', '[email protected]']))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_ngram_events_test'), in(lower(if(notEquals(toJSONString(events.properties.^email), '{}'), toJSONString(events.properties.^email), if(isNull(events.properties.email), NULL, if(and(in(ascii(toString(events.properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.properties.email)), tuple(91, 123))), toJSONString(events.properties.email), toString(events.properties.email))))), ['[email protected]', '[email protected]']))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
allow_experimental_object_type=1,
@@ -3345,7 +3345,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3367,7 +3367,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3389,7 +3389,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3411,7 +3411,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -3475,9 +3475,9 @@
# name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_1_materialized_on_events[new_events_schema]
'''
SELECT events.distinct_id AS distinct_id,
- if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email)))) AS email_value,
- isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))) AS is_not_set_result,
- or(isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), not(isNotNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))))) AS is_not_set_result_historical
+ if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email)))) AS email_value,
+ isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))) AS is_not_set_result,
+ or(isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), not(isNotNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))))) AS is_not_set_result_historical
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), equals(events.event, 'is_not_set_test'))
ORDER BY distinct_id ASC
@@ -3543,9 +3543,9 @@
# name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_3_not_materialized_on_events[new_events_schema]
'''
SELECT events.distinct_id AS distinct_id,
- if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email)))) AS email_value,
- isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))) AS is_not_set_result,
- or(isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), not(isNotNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))))) AS is_not_set_result_historical
+ if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email)))) AS email_value,
+ isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))) AS is_not_set_result,
+ or(isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), not(isNotNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))))) AS is_not_set_result_historical
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), equals(events.event, 'is_not_set_test'))
ORDER BY distinct_id ASC
@@ -3637,10 +3637,10 @@
'''
# ---
# name: TestPrinter.test_projection_pushdown_nested_subqueries_0_with_optimize_projections[new_events_schema]
- "SELECT outer.event AS event FROM (SELECT inner.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), '[]'), '{}'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000"
+ "SELECT outer.event AS event FROM (SELECT inner.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000"
# ---
# name: TestPrinter.test_projection_pushdown_nested_subqueries_1_without_optimize_projections[new_events_schema]
- 'SELECT outer.event AS event FROM (SELECT inner.uuid AS uuid, inner.event AS event, inner.properties AS properties, inner.timestamp AS timestamp, inner.distinct_id AS distinct_id, inner.elements_chain AS elements_chain, inner.created_at AS created_at, inner.`$session_id` AS `$session_id`, inner.`$window_id` AS `$window_id`, inner.person_mode AS person_mode, inner.person_id AS person_id, inner.`$group_0` AS `$group_0`, inner.`$group_1` AS `$group_1`, inner.`$group_2` AS `$group_2`, inner.`$group_3` AS `$group_3`, inner.`$group_4` AS `$group_4`, inner.elements_chain_href AS elements_chain_href, inner.elements_chain_texts AS elements_chain_texts, inner.elements_chain_ids AS elements_chain_ids, inner.elements_chain_elements AS elements_chain_elements, inner.event_issue_id AS event_issue_id, inner.issue_id AS issue_id, inner.issue_id_v2 AS issue_id_v2, inner.issue_name AS issue_name, inner.issue_description AS issue_description, inner.issue_status AS issue_status, inner.issue_assigned_user_id AS issue_assigned_user_id, inner.issue_assigned_role_id AS issue_assigned_role_id, inner.issue_first_seen AS issue_first_seen FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), \'[]\'), \'{}\'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), \'[]\'), \'{}\'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000'
+ 'SELECT outer.event AS event FROM (SELECT inner.uuid AS uuid, inner.event AS event, inner.properties AS properties, inner.timestamp AS timestamp, inner.distinct_id AS distinct_id, inner.elements_chain AS elements_chain, inner.created_at AS created_at, inner.`$session_id` AS `$session_id`, inner.`$window_id` AS `$window_id`, inner.person_mode AS person_mode, inner.person_id AS person_id, inner.`$group_0` AS `$group_0`, inner.`$group_1` AS `$group_1`, inner.`$group_2` AS `$group_2`, inner.`$group_3` AS `$group_3`, inner.`$group_4` AS `$group_4`, inner.elements_chain_href AS elements_chain_href, inner.elements_chain_texts AS elements_chain_texts, inner.elements_chain_ids AS elements_chain_ids, inner.elements_chain_elements AS elements_chain_elements, inner.event_issue_id AS event_issue_id, inner.issue_id AS issue_id, inner.issue_id_v2 AS issue_id_v2, inner.issue_name AS issue_name, inner.issue_description AS issue_description, inner.issue_status AS issue_status, inner.issue_assigned_user_id AS issue_assigned_user_id, inner.issue_assigned_role_id AS issue_assigned_role_id, inner.issue_first_seen AS issue_first_seen FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000'
# ---
# name: TestPrinter.test_projection_pushdown_no_asterisk_unchanged_0_with_optimize_projections[new_events_schema]
'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id FROM events_json AS events WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000'
@@ -3649,22 +3649,22 @@
'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id FROM events_json AS events WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000'
# ---
# name: TestPrinter.test_projection_pushdown_preserves_join_columns_0_with_optimize_projections[new_events_schema]
- "SELECT e.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), '[]'), '{}'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT 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_2)s), person.version), plus(now64(6, %(hogql_val_3)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000"
+ "SELECT e.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT 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_2)s), person.version), plus(now64(6, %(hogql_val_3)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000"
# ---
# name: TestPrinter.test_projection_pushdown_preserves_join_columns_1_without_optimize_projections[new_events_schema]
- 'SELECT e.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), \'[]\'), \'{}\'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), \'[]\'), \'{}\'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT 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_4)s), person.version), plus(now64(6, %(hogql_val_5)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000'
+ 'SELECT e.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT 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_4)s), person.version), plus(now64(6, %(hogql_val_5)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000'
# ---
# name: TestPrinter.test_projection_pushdown_preserves_where_columns_0_with_optimize_projections[new_events_schema]
- "SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), '[]'), '{}'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_2)s) LIMIT 50000"
+ "SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_2)s) LIMIT 50000"
# ---
# name: TestPrinter.test_projection_pushdown_preserves_where_columns_1_without_optimize_projections[new_events_schema]
- 'SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), \'[]\'), \'{}\'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), \'[]\'), \'{}\'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_4)s) LIMIT 50000'
+ 'SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_4)s) LIMIT 50000'
# ---
# name: TestPrinter.test_projection_pushdown_simple_asterisk_subquery_0_with_optimize_projections[new_events_schema]
- "SELECT sub.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), '[]'), '{}'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub LIMIT 50000"
+ "SELECT sub.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), '{}'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_1)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub LIMIT 50000"
# ---
# name: TestPrinter.test_projection_pushdown_simple_asterisk_subquery_1_without_optimize_projections[new_events_schema]
- 'SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(nullIf(toString(events.properties.`$exception_issue_id`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_issue_id`), \'[]\'), \'{}\'), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), \'\')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), \'[]\'), \'{}\'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub LIMIT 50000'
+ 'SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat(\'{\', arrayStringConcat(arrayConcat(arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), arrayFilter(kv -> not (kv.2 = \'[]\' and kv.1 in (\'$exception_functions\', \'$exception_list\', \'$exception_sources\', \'$exception_types\', \'$exception_values\', \'$mcp_listed_tool_names\')) and not (kv.2 = \'""\' and kv.1 in (\'$browser\', \'$browser_language\', \'$browser_version\', \'$config_defaults\', \'$device_type\', \'$geoip_city_name\', \'$geoip_continent_code\', \'$geoip_continent_name\', \'$geoip_country_code\', \'$geoip_country_name\', \'$geoip_subdivision_1_name\', \'$geoip_time_zone\', \'$group_0\', \'$group_1\', \'$group_2\', \'$group_3\', \'$group_4\', \'$lib\', \'$lib_version\', \'$os\', \'$os_version\', \'$session_id\', \'$timezone\', \'$window_id\')) and kv.1 != \'$feature_flags\', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat(\'$feature/\', key)), \':\', if(value in (\'true\', \'false\'), value, toJSONString(multiIf(value = \'$false\', \'false\', value = \'$true\', \'true\', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat(\'"$active_feature_flags":\', toJSONString(mapKeys(mapFilter((key, value) -> value not in (\'\', \'false\'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), \':\', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), \',\'), \'}\') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.properties.`$session_id` AS `$session_id`, events.properties.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.properties.`$group_0` AS `$group_0`, events.properties.`$group_1` AS `$group_1`, events.properties.`$group_2` AS `$group_2`, events.properties.`$group_3` AS `$group_3`, events.properties.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^`$exception_issue_id`), \'{}\'), toJSONString(events.properties.^`$exception_issue_id`), if(isNull(events.properties.`$exception_issue_id`), NULL, if(and(in(ascii(toString(events.properties.`$exception_issue_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_issue_id`)), tuple(91, 123))), toJSONString(events.properties.`$exception_issue_id`), toString(events.properties.`$exception_issue_id`)))), %(hogql_val_3)s) AS event_issue_id, events__fingerprint_issue_state.issue_id AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), \'{}\'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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 equals(events.team_id, 99999)) AS sub LIMIT 50000'
# ---
# name: TestPrinter.test_s3_tables_global_join_anonymous_tables_0_global_joins_with_optimize[new_events_schema]
"SELECT e.event AS event, ij.remote_id AS remote_id FROM events_json AS e GLOBAL INNER JOIN (SELECT remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT 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_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000"
diff --git a/posthog/hogql/printer/test/test_printer.py b/posthog/hogql/printer/test/test_printer.py
index bf8eec167e0b..1073e403e7e2 100644
--- a/posthog/hogql/printer/test/test_printer.py
+++ b/posthog/hogql/printer/test/test_printer.py
@@ -1786,10 +1786,6 @@ class TestPrinter(BaseTest):
else:
assert "properties_group_custom" in enabled_response.clickhouse
assert "properties_group_custom" in optimized_response.clickhouse
- if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- labels = labels - {"empty_string"}
- if "null" in labels:
- labels = labels | {"empty_string"}
assert {row[0] for row in disabled_response.results} == labels
assert {row[0] for row in enabled_response.results} == labels
assert {row[0] for row in optimized_response.results} == labels
@@ -6162,7 +6158,8 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):
index_name = get_minmax_index_name(mat_col.name)
if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- expected_lt_mango = [("d_low",)]
+ # The native table has no materialized column, so '' and 'null' are values in both flavors.
+ expected_lt_mango = [("d_empty",), ("d_low",)]
expected_gte_mango = [("d_high",), ("d_mid",), ("d_null_str",)]
lt_result = execute_hogql_query(
@@ -6277,7 +6274,7 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):
Expected behavior:
- with_email: is_not_set=0 - property has a value
- - test_with_empty_string: is_not_set=1 for native String paths and materialized columns, otherwise 0
+ - test_with_empty_string: is_not_set=1 for legacy materialized columns, otherwise 0
- with_null: is_not_set=1 - null is treated as "not set"
- without: is_not_set=1 - property doesn't exist
@@ -6377,8 +6374,8 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):
)
assert result.clickhouse
- # Native String paths and materialized string columns use empty strings for missing values.
- materialized_column_nullifies_empty_string = is_materialized or (
+ # A legacy materialized column reads '' as NULL; the native table has none, so a read on events keeps ''.
+ materialized_column_nullifies_empty_string = is_materialized and not (
settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA
and poe_mode == PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS
)
@@ -6887,8 +6884,6 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):
and not settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA
):
ilike_expected = ilike_expected_if_non_nullable
- if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- ilike_expected = (ilike_expected | {""}) if pattern == "None" else ilike_expected - {""}
pattern_expr = ast.Constant(value=pattern if pattern != "None" else None)
ilike_result = execute_hogql_query(
team=self.team,
@@ -6984,8 +6979,6 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):
):
in_expected = in_expected_if_non_nullable
- if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:
- in_expected = in_expected - {""}
in_values_exprs: list[ast.Expr] = [ast.Constant(value=v) for v in in_values]
in_tuple = ast.Tuple(exprs=in_values_exprs)
diff --git a/posthog/hogql/test/__snapshots__/test_property_skip_indexes.new_events_schema.ambr b/posthog/hogql/test/__snapshots__/test_property_skip_indexes.new_events_schema.ambr
index 06092cb2a572..f4c8e39ce0fb 100644
--- a/posthog/hogql/test/__snapshots__/test_property_skip_indexes.new_events_schema.ambr
+++ b/posthog/hogql/test/__snapshots__/test_property_skip_indexes.new_events_schema.ambr
@@ -43,7 +43,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%0%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%0%'), 0))
LIMIT 50000
'''
# ---
@@ -51,7 +51,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
LIMIT 50000
'''
# ---
@@ -59,7 +59,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
LIMIT 50000
'''
# ---
@@ -75,7 +75,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(parseDateTime64BestEffortOrNull(if(notEquals(toJSONString(events.properties.^lt_datetime_prop), '{}'), toJSONString(events.properties.^lt_datetime_prop), if(isNull(nullIf(toString(events.properties.lt_datetime_prop), '')), NULL, if(and(in(ascii(toString(events.properties.lt_datetime_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.lt_datetime_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.lt_datetime_prop), '[]'), '{}'), toString(events.properties.lt_datetime_prop)))), 6, 'UTC'), toDateTime64('2024-01-15 10:30:00.000000', 6, 'UTC')), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(parseDateTime64BestEffortOrNull(if(notEquals(toJSONString(events.properties.^lt_datetime_prop), '{}'), toJSONString(events.properties.^lt_datetime_prop), if(isNull(events.properties.lt_datetime_prop), NULL, if(and(in(ascii(toString(events.properties.lt_datetime_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.lt_datetime_prop)), tuple(91, 123))), toJSONString(events.properties.lt_datetime_prop), toString(events.properties.lt_datetime_prop)))), 6, 'UTC'), toDateTime64('2024-01-15 10:30:00.000000', 6, 'UTC')), 0))
LIMIT 50000
'''
# ---
@@ -107,7 +107,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), tuple('5', '')))
+ WHERE and(equals(events.team_id, 99999), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), tuple('5', '')))
LIMIT 50000
'''
# ---
@@ -115,7 +115,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -131,7 +131,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -139,7 +139,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(greater(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(greater(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -155,7 +155,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%5%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%5%'), 0))
LIMIT 50000
'''
# ---
@@ -163,7 +163,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '[0-9]'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '[0-9]'), 0))
LIMIT 50000
'''
# ---
@@ -171,7 +171,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%value_that_is_long_enough%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%value_that_is_long_enough%'), 0))
LIMIT 50000
'''
# ---
@@ -179,7 +179,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%null%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 0))
LIMIT 50000
'''
# ---
@@ -235,7 +235,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%5%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%5%'), 0))
LIMIT 50000
'''
# ---
@@ -243,7 +243,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
LIMIT 50000
'''
# ---
@@ -267,7 +267,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -275,7 +275,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(greater(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(greater(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -283,7 +283,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(lessOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(lessOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -291,7 +291,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -307,7 +307,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%5%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%5%'), 0))
LIMIT 50000
'''
# ---
@@ -315,7 +315,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '[0-9]'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '[0-9]'), 0))
LIMIT 50000
'''
# ---
@@ -323,7 +323,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), toDateTime64('2024-01-15 10:30:00.000000', 6, 'UTC')), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), toDateTime64('2024-01-15 10:30:00.000000', 6, 'UTC')), 0))
LIMIT 50000
'''
# ---
@@ -379,7 +379,7 @@
'''
SELECT events.distinct_id AS distinct_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '500'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '500'), 0))
ORDER BY events.distinct_id ASC
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -401,7 +401,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), 'apple'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), 'apple'), 0))
LIMIT 50000
'''
# ---
@@ -409,7 +409,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '2024-01-15'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '2024-01-15'), 0))
LIMIT 50000
'''
# ---
@@ -433,7 +433,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop)))), '2024-01-15T10:30:00Z'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))), '2024-01-15T10:30:00Z'), 0))
LIMIT 50000
'''
# ---
@@ -449,7 +449,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%value_that_is_long_enough%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%value_that_is_long_enough%'), 0))
LIMIT 50000
'''
# ---
@@ -457,7 +457,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%abc%'), 1))
+ WHERE and(equals(events.team_id, 99999), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%abc%'), 1))
LIMIT 50000
'''
# ---
@@ -481,7 +481,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), 'value_that_is_long_enough'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'value_that_is_long_enough'), 0))
LIMIT 50000
'''
# ---
@@ -497,7 +497,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
LIMIT 50000
'''
# ---
@@ -505,7 +505,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))
LIMIT 50000
'''
# ---
@@ -529,7 +529,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(nullIf(toString(events.properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.test_prop), '[]'), '{}'), toString(events.properties.test_prop))))), '%5%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(and(in(ascii(toString(events.properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.test_prop)), tuple(91, 123))), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%5%'), 0))
LIMIT 50000
'''
# ---
@@ -537,7 +537,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(parseDateTime64BestEffortOrNull(if(notEquals(toJSONString(events.properties.^typed_datetime_prop), '{}'), toJSONString(events.properties.^typed_datetime_prop), if(isNull(nullIf(toString(events.properties.typed_datetime_prop), '')), NULL, if(and(in(ascii(toString(events.properties.typed_datetime_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.typed_datetime_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.typed_datetime_prop), '[]'), '{}'), toString(events.properties.typed_datetime_prop)))), 6, 'UTC'), '2024-01-05 00:00:00'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(parseDateTime64BestEffortOrNull(if(notEquals(toJSONString(events.properties.^typed_datetime_prop), '{}'), toJSONString(events.properties.^typed_datetime_prop), if(isNull(events.properties.typed_datetime_prop), NULL, if(and(in(ascii(toString(events.properties.typed_datetime_prop)), tuple(91, 123)), in(ascii(toJSONString(events.properties.typed_datetime_prop)), tuple(91, 123))), toJSONString(events.properties.typed_datetime_prop), toString(events.properties.typed_datetime_prop)))), 6, 'UTC'), '2024-01-05 00:00:00'), 0))
LIMIT 50000
'''
# ---
@@ -593,7 +593,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(nullIf(toString(events.person_properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.test_prop), '[]'), '{}'), toString(events.person_properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(less(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(events.person_properties.test_prop), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), toJSONString(events.person_properties.test_prop), toString(events.person_properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -601,7 +601,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(greater(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(nullIf(toString(events.person_properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.test_prop), '[]'), '{}'), toString(events.person_properties.test_prop)))), 'mango'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(greater(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(events.person_properties.test_prop), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), toJSONString(events.person_properties.test_prop), toString(events.person_properties.test_prop)))), 'mango'), 0))
LIMIT 50000
'''
# ---
@@ -617,7 +617,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(nullIf(toString(events.person_properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.test_prop), '[]'), '{}'), toString(events.person_properties.test_prop))))), '%5%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(events.person_properties.test_prop), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), toJSONString(events.person_properties.test_prop), toString(events.person_properties.test_prop))))), '%5%'), 0))
LIMIT 50000
'''
# ---
@@ -625,7 +625,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(nullIf(toString(events.person_properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.test_prop), '[]'), '{}'), toString(events.person_properties.test_prop))))), '%value_that_is_long_enough%'), 0))
+ WHERE and(equals(events.team_id, 99999), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(events.person_properties.test_prop), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), toJSONString(events.person_properties.test_prop), toString(events.person_properties.test_prop))))), '%value_that_is_long_enough%'), 0))
LIMIT 50000
'''
# ---
@@ -649,7 +649,7 @@
'''
SELECT count() AS `count()`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(nullIf(toString(events.person_properties.test_prop), '')), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.test_prop), '[]'), '{}'), toString(events.person_properties.test_prop))))))
+ WHERE and(equals(events.team_id, 99999), isNotNull(if(notEquals(toJSONString(events.person_properties.^test_prop), '{}'), toJSONString(events.person_properties.^test_prop), if(isNull(events.person_properties.test_prop), NULL, if(and(in(ascii(toString(events.person_properties.test_prop)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.test_prop)), tuple(91, 123))), toJSONString(events.person_properties.test_prop), toString(events.person_properties.test_prop))))))
LIMIT 50000
'''
# ---
diff --git a/posthog/hogql/test/__snapshots__/test_query.new_events_schema.ambr b/posthog/hogql/test/__snapshots__/test_query.new_events_schema.ambr
index f8a1fc94b8ce..ed63f67cc075 100644
--- a/posthog/hogql/test/__snapshots__/test_query.new_events_schema.ambr
+++ b/posthog/hogql/test/__snapshots__/test_query.new_events_schema.ambr
@@ -9,7 +9,7 @@
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0)
- SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), and(equals(events.event, %(hogql_val_12)s), isNotNull(events__fingerprint_issue_state.issue_id), or(and(greater(toTimeZone(events.timestamp, %(hogql_val_13)s), parseDateTime64BestEffort(%(hogql_val_14)s, 6, %(hogql_val_15)s)), less(toTimeZone(events.timestamp, %(hogql_val_16)s), parseDateTime64BestEffort(%(hogql_val_17)s, 6, %(hogql_val_18)s))), and(greater(toTimeZone(events.timestamp, %(hogql_val_19)s), toDateTime(%(hogql_val_20)s, %(hogql_val_21)s)), less(toTimeZone(events.timestamp, %(hogql_val_22)s), toDateTime64(%(hogql_val_23)s, 6, %(hogql_val_24)s))))))
GROUP BY events__fingerprint_issue_state.issue_id
ORDER BY occurrences DESC
@@ -172,7 +172,7 @@
# name: TestQuery.test_hogql_unnecessary_ifnull[new_events_schema]
'''
-- ClickHouse
- SELECT toDate(toTimeZone(events.timestamp, %(hogql_val_0)s)) AS timestamp, JSONExtractInt(ifNull(if(notEquals(toJSONString(events.properties.^field), '{}'), toJSONString(events.properties.^field), if(isNull(nullIf(toString(events.properties.field), '')), NULL, nullIf(nullIf(toJSONString(events.properties.field), '[]'), '{}'))), '')) AS json_int
+ SELECT toDate(toTimeZone(events.timestamp, %(hogql_val_0)s)) AS timestamp, JSONExtractInt(ifNull(if(notEquals(toJSONString(events.properties.^field), '{}'), toJSONString(events.properties.^field), if(isNull(events.properties.field), NULL, toJSONString(events.properties.field))), '')) AS json_int
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), greaterOrEquals(timestamp, addDays(today(), -10)), equals(json_int, 17))
LIMIT 1
@@ -231,9 +231,9 @@
-- ClickHouse
SELECT e.event AS event, s.session_id AS session_id
FROM (
- SELECT e.event AS event, if(notEquals(toJSONString(e.properties.^`$$$session_id`), '{}'), toJSONString(e.properties.^`$$$session_id`), if(isNull(nullIf(toString(e.properties.`$$$session_id`), '')), NULL, if(and(in(ascii(toString(e.properties.`$$$session_id`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$$$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$$$session_id`), '[]'), '{}'), toString(e.properties.`$$$session_id`)))) AS `properties__$$$session_id`
+ SELECT e.event AS event, if(notEquals(toJSONString(e.properties.^`$$$session_id`), '{}'), toJSONString(e.properties.^`$$$session_id`), if(isNull(e.properties.`$$$session_id`), NULL, if(and(in(ascii(toString(e.properties.`$$$session_id`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$$$session_id`)), tuple(91, 123))), toJSONString(e.properties.`$$$session_id`), toString(e.properties.`$$$session_id`)))) AS `properties__$$$session_id`
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), isNotNull(if(notEquals(toJSONString(e.properties.^`$$$session_id`), '{}'), toJSONString(e.properties.^`$$$session_id`), if(isNull(nullIf(toString(e.properties.`$$$session_id`), '')), NULL, if(and(in(ascii(toString(e.properties.`$$$session_id`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$$$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$$$session_id`), '[]'), '{}'), toString(e.properties.`$$$session_id`))))))
+ WHERE and(equals(e.team_id, 99999), isNotNull(if(notEquals(toJSONString(e.properties.^`$$$session_id`), '{}'), toJSONString(e.properties.^`$$$session_id`), if(isNull(e.properties.`$$$session_id`), NULL, if(and(in(ascii(toString(e.properties.`$$$session_id`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$$$session_id`)), tuple(91, 123))), toJSONString(e.properties.`$$$session_id`), toString(e.properties.`$$$session_id`))))))
LIMIT 10) AS e LEFT JOIN (
SELECT session_replay_events.session_id AS session_id
FROM session_replay_events
@@ -752,7 +752,7 @@
# name: TestQuery.test_query_select_person_with_poe_without_joins[new_events_schema]
'''
-- ClickHouse
- SELECT events.event AS event, toTimeZone(events.timestamp, %(hogql_val_0)s) AS timestamp, events.person_id AS id, if(notEquals(toJSONString(events.person_properties.^sneaky_mail), '{}'), toJSONString(events.person_properties.^sneaky_mail), if(isNull(nullIf(toString(events.person_properties.sneaky_mail), '')), NULL, if(and(in(ascii(toString(events.person_properties.sneaky_mail)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.sneaky_mail)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.sneaky_mail), '[]'), '{}'), toString(events.person_properties.sneaky_mail)))) AS sneaky_mail
+ SELECT events.event AS event, toTimeZone(events.timestamp, %(hogql_val_0)s) AS timestamp, events.person_id AS id, if(notEquals(toJSONString(events.person_properties.^sneaky_mail), '{}'), toJSONString(events.person_properties.^sneaky_mail), if(isNull(events.person_properties.sneaky_mail), NULL, if(and(in(ascii(toString(events.person_properties.sneaky_mail)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.sneaky_mail)), tuple(91, 123))), toJSONString(events.person_properties.sneaky_mail), toString(events.person_properties.sneaky_mail)))) AS sneaky_mail
FROM events_json AS events
WHERE equals(events.team_id, 99999)
LIMIT 10
@@ -767,10 +767,10 @@
# name: TestQuery.test_select_person_on_events[new_events_schema]
'''
-- ClickHouse
- SELECT if(notEquals(toJSONString(s.person_properties.^sneaky_mail), '{}'), toJSONString(s.person_properties.^sneaky_mail), if(isNull(nullIf(toString(s.person_properties.sneaky_mail), '')), NULL, if(and(in(ascii(toString(s.person_properties.sneaky_mail)), tuple(91, 123)), in(ascii(toJSONString(s.person_properties.sneaky_mail)), tuple(91, 123))), nullIf(nullIf(toJSONString(s.person_properties.sneaky_mail), '[]'), '{}'), toString(s.person_properties.sneaky_mail)))) AS sneaky_mail, count() AS `count()`
+ SELECT if(notEquals(toJSONString(s.person_properties.^sneaky_mail), '{}'), toJSONString(s.person_properties.^sneaky_mail), if(isNull(s.person_properties.sneaky_mail), NULL, if(and(in(ascii(toString(s.person_properties.sneaky_mail)), tuple(91, 123)), in(ascii(toJSONString(s.person_properties.sneaky_mail)), tuple(91, 123))), toJSONString(s.person_properties.sneaky_mail), toString(s.person_properties.sneaky_mail)))) AS sneaky_mail, count() AS `count()`
FROM events_json AS s
WHERE equals(s.team_id, 99999)
- GROUP BY if(notEquals(toJSONString(s.person_properties.^sneaky_mail), '{}'), toJSONString(s.person_properties.^sneaky_mail), if(isNull(nullIf(toString(s.person_properties.sneaky_mail), '')), NULL, if(and(in(ascii(toString(s.person_properties.sneaky_mail)), tuple(91, 123)), in(ascii(toJSONString(s.person_properties.sneaky_mail)), tuple(91, 123))), nullIf(nullIf(toJSONString(s.person_properties.sneaky_mail), '[]'), '{}'), toString(s.person_properties.sneaky_mail))))
+ GROUP BY if(notEquals(toJSONString(s.person_properties.^sneaky_mail), '{}'), toJSONString(s.person_properties.^sneaky_mail), if(isNull(s.person_properties.sneaky_mail), NULL, if(and(in(ascii(toString(s.person_properties.sneaky_mail)), tuple(91, 123)), in(ascii(toJSONString(s.person_properties.sneaky_mail)), tuple(91, 123))), toJSONString(s.person_properties.sneaky_mail), toString(s.person_properties.sneaky_mail))))
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, json_type_escape_dots_in_keys=1, output_format_json_escape_forward_slashes=0
@@ -836,10 +836,10 @@
FROM (
SELECT col_a AS col_a, groupArray(tuple(col_b, col_c)) AS g
FROM (
- SELECT if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(nullIf(toString(events.properties.index), '')), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.index), '[]'), '{}'), toString(events.properties.index)))) AS col_a, events.event AS col_b, count() AS col_c
+ SELECT if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(events.properties.index), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), toJSONString(events.properties.index), toString(events.properties.index)))) AS col_a, events.event AS col_b, count() AS col_c
FROM events_json AS events
WHERE equals(events.team_id, 99999)
- GROUP BY if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(nullIf(toString(events.properties.index), '')), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.index), '[]'), '{}'), toString(events.properties.index)))), events.event)
+ GROUP BY if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(events.properties.index), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), toJSONString(events.properties.index), toString(events.properties.index)))), events.event)
GROUP BY col_a)
GROUP BY col_a
ORDER BY col_a ASC
@@ -864,10 +864,10 @@
'''
-- ClickHouse
WITH PIVOT_TABLE_COL_ABC AS (
- SELECT if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(nullIf(toString(events.properties.index), '')), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.index), '[]'), '{}'), toString(events.properties.index)))) AS col_a, events.event AS col_b, count() AS col_c
+ SELECT if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(events.properties.index), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), toJSONString(events.properties.index), toString(events.properties.index)))) AS col_a, events.event AS col_b, count() AS col_c
FROM events_json AS events
WHERE equals(events.team_id, 99999)
- GROUP BY if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(nullIf(toString(events.properties.index), '')), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.index), '[]'), '{}'), toString(events.properties.index)))), events.event), PIVOT_FUNCTION_1 AS (
+ GROUP BY if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(events.properties.index), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), toJSONString(events.properties.index), toString(events.properties.index)))), events.event), PIVOT_FUNCTION_1 AS (
SELECT PIVOT_TABLE_COL_ABC.col_a AS col_a, groupArray(tuple(PIVOT_TABLE_COL_ABC.col_b, PIVOT_TABLE_COL_ABC.col_c)) AS g
FROM PIVOT_TABLE_COL_ABC
GROUP BY PIVOT_TABLE_COL_ABC.col_a), PIVOT_FUNCTION_2 AS (
@@ -901,10 +901,10 @@
'''
-- ClickHouse
WITH PIVOT_TABLE_COL_ABC AS (
- SELECT if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(nullIf(toString(events.properties.index), '')), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.index), '[]'), '{}'), toString(events.properties.index)))) AS col_a, events.event AS col_b, count() AS col_c
+ SELECT if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(events.properties.index), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), toJSONString(events.properties.index), toString(events.properties.index)))) AS col_a, events.event AS col_b, count() AS col_c
FROM events_json AS events
WHERE equals(events.team_id, 99999)
- GROUP BY if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(nullIf(toString(events.properties.index), '')), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.index), '[]'), '{}'), toString(events.properties.index)))), events.event), PIVOT_FUNCTION_1 AS (
+ GROUP BY if(notEquals(toJSONString(events.properties.^index), '{}'), toJSONString(events.properties.^index), if(isNull(events.properties.index), NULL, if(and(in(ascii(toString(events.properties.index)), tuple(91, 123)), in(ascii(toJSONString(events.properties.index)), tuple(91, 123))), toJSONString(events.properties.index), toString(events.properties.index)))), events.event), PIVOT_FUNCTION_1 AS (
SELECT PIVOT_TABLE_COL_ABC.col_a AS col_a, groupArray(tuple(PIVOT_TABLE_COL_ABC.col_b, PIVOT_TABLE_COL_ABC.col_c)) AS g
FROM PIVOT_TABLE_COL_ABC
GROUP BY PIVOT_TABLE_COL_ABC.col_a), PIVOT_FUNCTION_2 AS (
diff --git a/posthog/hogql/test/test_property.py b/posthog/hogql/test/test_property.py
index f01404d52042..6eb8fefdb7fd 100644
--- a/posthog/hogql/test/test_property.py
+++ b/posthog/hogql/test/test_property.py
@@ -2520,7 +2520,7 @@ class TestPropertyIsSetIsNotSetWithData(APIBaseTest):
"string_empty_prop",
"",
PropertyType.String,
- False if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else self.ONLY_WHEN_NOT_LEGACY_MATERIALIZED,
+ self.ONLY_WHEN_NOT_LEGACY_MATERIALIZED,
),
("string_null_literal_prop", "null", PropertyType.String, self.ONLY_WHEN_NOT_LEGACY_MATERIALIZED),
("string_null_prop", None, PropertyType.String, False),
diff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.py
index cb8651c64f3e..1bd42a6cbe8a 100644
--- a/posthog/hogql/test/test_query.py
+++ b/posthog/hogql/test/test_query.py
@@ -1198,8 +1198,7 @@ class TestQuery(ClickhouseTestMixin, APIBaseTest):
response.results,
[
(
- # The native-JSON table treats an empty value as absent, like a materialized column does.
- None if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else "",
+ "",
None, # null
None, # undefined
"0", # zero string
diff --git a/posthog/hogql/test/utils.py b/posthog/hogql/test/utils.py
index 672cfbf4606a..f0465c24254e 100644
--- a/posthog/hogql/test/utils.py
+++ b/posthog/hogql/test/utils.py
@@ -13,6 +13,8 @@ from posthog.schema import HogQLQueryModifiers
from posthog.hogql.escape_sql import escape_clickhouse_identifier
from posthog.hogql.query import execute_hogql_query
+from posthog.clickhouse.events_json import EVENTS_PROPERTIES_JSON_SUBCOLUMNS, PERSON_PROPERTIES_JSON_SUBCOLUMNS
+
def execute_hogql_query_with_timings(*args, **kwargs):
modifiers = kwargs.get("modifiers") or HogQLQueryModifiers()
@@ -165,25 +167,41 @@ def pretty_dataclasses(obj, seen=None, indent=0):
return str(obj)
+def _json_text_sql(field: str, *, declared: bool) -> str:
+ # A declared array column holds [] for a missing key, so its empty containers read as NULL.
+ if declared:
+ return f"nullIf(nullIf(toJSONString({field}), '[]'), '{{}}')"
+ return f"toJSONString({field})"
+
+
def json_dynamic_read_sql_from_parts(
- field: Callable[[], str], sub_object: Callable[[], str], *, as_json: bool = False, with_sub_object: bool = True
+ field: Callable[[], str],
+ sub_object: Callable[[], str],
+ *,
+ as_json: bool = False,
+ with_sub_object: bool = True,
+ declared: bool = False,
) -> str:
"""The ClickHouse SQL the resolver prints for a property read on the native-JSON events table.
`field` and `sub_object` are called once per occurrence, so a caller whose key is parameterized can hand out the
next `%(hogql_val_N)s` placeholder each time. The shape mirrors `_json_subcolumn_value_expr`: a non-empty
- sub-object wins, an empty scalar reads as NULL, containers render as JSON.
+ sub-object wins, a missing key reads as NULL, containers render as JSON. A declared path cannot hold NULL, so
+ its '' and [] defaults read as NULL as well.
"""
sub_object_read = f"toJSONString({sub_object()})" if with_sub_object else ""
sub_object_again = f"toJSONString({sub_object()})" if with_sub_object else ""
- empty_check = f"isNull(nullIf(toString({field()}), ''))"
+ if declared:
+ empty_check = f"isNull(nullIf(toString({field()}), ''))"
+ else:
+ empty_check = f"isNull({field()})"
if as_json:
- typed = f"nullIf(nullIf(toJSONString({field()}), '[]'), '{{}}')"
+ typed = _json_text_sql(field(), declared=declared)
else:
is_container = (
f"and(in(ascii(toString({field()})), tuple(91, 123)), in(ascii(toJSONString({field()})), tuple(91, 123)))"
)
- typed = f"if({is_container}, nullIf(nullIf(toJSONString({field()}), '[]'), '{{}}'), toString({field()}))"
+ typed = f"if({is_container}, {_json_text_sql(field(), declared=declared)}, toString({field()}))"
scalar_or_null = f"if({empty_check}, NULL, {typed})"
if not with_sub_object:
return scalar_or_null
@@ -194,12 +212,20 @@ def json_dynamic_read_sql(root: str, path: Sequence[str | int], *, as_json: bool
"""`json_dynamic_read_sql_from_parts` for a literal key path under `root` (e.g. `events.properties`).
An integer key is an array index; the read then has no sub-object branch, because a sub-object only exists
- for a plain key path.
+ for a plain key path, and it scrubs like a declared path, because only a declared array is indexed in place.
"""
field = root
for key in path:
field += f"[{key}]" if isinstance(key, int) else f".{escape_clickhouse_identifier(key)}"
if any(isinstance(key, int) for key in path):
- return json_dynamic_read_sql_from_parts(lambda: field, lambda: field, as_json=as_json, with_sub_object=False)
+ return json_dynamic_read_sql_from_parts(
+ lambda: field, lambda: field, as_json=as_json, with_sub_object=False, declared=True
+ )
+ declared_types = (
+ PERSON_PROPERTIES_JSON_SUBCOLUMNS if root.endswith(".person_properties") else EVENTS_PROPERTIES_JSON_SUBCOLUMNS
+ )
+ declared = ".".join(str(key) for key in path) in declared_types
escaped = ".".join(escape_clickhouse_identifier(key) for key in path if isinstance(key, str))
- return json_dynamic_read_sql_from_parts(lambda: field, lambda: f"{root}.^{escaped}", as_json=as_json)
+ return json_dynamic_read_sql_from_parts(
+ lambda: field, lambda: f"{root}.^{escaped}", as_json=as_json, declared=declared
+ )
diff --git a/posthog/hogql/transforms/clickhouse_property_resolution.py b/posthog/hogql/transforms/clickhouse_property_resolution.py
index d108525d7cf1..b60be81dbb09 100644
--- a/posthog/hogql/transforms/clickhouse_property_resolution.py
+++ b/posthog/hogql/transforms/clickhouse_property_resolution.py
@@ -434,36 +434,44 @@ def _json_subcolumn_access(
return value
-def _is_declared_array_path(
+def _declared_json_path_type(
field_type: ast.FieldType, keys: Sequence[str | int], source: MaterializedPropertySource
-) -> bool:
- """Whether the native events table declares an array type for the path, so that every row holds an array there."""
- if source.json_column is not None or field_type.name != "properties":
- return False
+) -> str:
+ """The type the native table declares for the path, or '' for a Dynamic path.
+
+ A declared column cannot hold NULL, so a missing key sits there as the type's default ('' or []) and the read has
+ to map that default back to NULL. A Dynamic path is NULL when the key is missing, so an empty value there is a
+ value the customer sent and reads as legacy reads it.
+ """
+ if source.json_column is not None:
+ return ""
+ is_person = False
table_type: ast.Type | None = field_type.table_type
- while isinstance(table_type, (ast.TableAliasType, ast.ColumnAliasedTableType)):
+ while isinstance(table_type, (ast.TableAliasType, ast.ColumnAliasedTableType, ast.VirtualTableType)):
+ is_person = is_person or isinstance(table_type, ast.VirtualTableType)
table_type = table_type.table_type
if not isinstance(table_type, ast.TableType):
- return False
- declared_type = EVENTS_PROPERTIES_JSON_SUBCOLUMNS.get(".".join(str(key) for key in keys), "")
- return declared_type.startswith("Array(")
+ return ""
+ declared_types = PERSON_PROPERTIES_JSON_SUBCOLUMNS if is_person else EVENTS_PROPERTIES_JSON_SUBCOLUMNS
+ return declared_types.get(".".join(str(key) for key in keys), "")
-def _dynamic_json_scalar_string_expr(value: ast.Expr, *, as_json: bool) -> ast.Expr:
- json_value = ast.Call(
- name="nullIf",
- args=[
- ast.Call(
- name="nullIf",
- args=[
- ast.Call(name="toJSONString", args=[clone_expr(value)], type=ast.StringType(nullable=False)),
- _sentinel("[]"),
- ],
- ),
- _sentinel("{}"),
- ],
- type=ast.StringType(nullable=True),
- )
+def _is_declared_array_path(
+ field_type: ast.FieldType, keys: Sequence[str | int], source: MaterializedPropertySource
+) -> bool:
+ """Whether the native events table declares an array type for the path, so that every row holds an array there."""
+ return _declared_json_path_type(field_type, keys, source).startswith("Array(")
+
+
+def _dynamic_json_scalar_string_expr(value: ast.Expr, *, as_json: bool, declared: bool) -> ast.Expr:
+ json_value: ast.Expr = ast.Call(name="toJSONString", args=[clone_expr(value)], type=ast.StringType(nullable=False))
+ if declared:
+ # A declared array column holds [] for a missing key, so an empty container reads as NULL there.
+ json_value = ast.Call(
+ name="nullIf",
+ args=[ast.Call(name="nullIf", args=[json_value, _sentinel("[]")]), _sentinel("{}")],
+ type=ast.StringType(nullable=True),
+ )
if as_json:
return json_value
@@ -532,19 +540,19 @@ def _json_subcolumn_value_expr(
return ast.PropertyAccess(expr=document, keys=list(keys[index_position:]), type=ast.StringType(nullable=True))
value = _json_subcolumn_access(field_type, keys, source=source, is_nullable=True)
- scalar_value = _dynamic_json_scalar_string_expr(value, as_json=as_json)
+ # A declared column stores a missing key as '', and an index into a declared array reads '' past its end, so both
+ # map '' back to NULL. A Dynamic path is NULL for a missing key and keeps '' as a value.
+ declared = index_position is not None or bool(_declared_json_path_type(field_type, keys, source))
+ scalar_value = _dynamic_json_scalar_string_expr(value, as_json=as_json, declared=declared)
+ missing: ast.Expr = ast.Call(name="isNull", args=[clone_expr(value)])
+ if declared:
+ missing = ast.Call(
+ name="isNull",
+ args=[ast.Call(name="nullIf", args=[ast.Call(name="toString", args=[clone_expr(value)]), _sentinel("")])],
+ )
scalar_or_null = ast.Call(
name="if",
- args=[
- ast.Call(
- name="isNull",
- args=[
- ast.Call(name="nullIf", args=[ast.Call(name="toString", args=[clone_expr(value)]), _sentinel("")])
- ],
- ),
- ast.Constant(value=None, type=ast.StringType(nullable=True)),
- scalar_value,
- ],
+ args=[missing, ast.Constant(value=None, type=ast.StringType(nullable=True)), scalar_value],
type=ast.StringType(nullable=True),
)
if index_position is not None:
diff --git a/posthog/hogql/transforms/test/__snapshots__/test_property_types.new_events_schema.ambr b/posthog/hogql/transforms/test/__snapshots__/test_property_types.new_events_schema.ambr
index 00391181eb95..3ff8335521a8 100644
--- a/posthog/hogql/transforms/test/__snapshots__/test_property_types.new_events_schema.ambr
+++ b/posthog/hogql/transforms/test/__snapshots__/test_property_types.new_events_schema.ambr
@@ -79,7 +79,7 @@
# name: TestPropertyTypes.test_resolve_property_types_event_person_poe_on[new_events_schema]
'''
- SELECT parseDateTime64BestEffortOrNull(if(notEquals(toJSONString(events.person_properties.^provided_timestamp), '{}'), toJSONString(events.person_properties.^provided_timestamp), if(isNull(nullIf(toString(events.person_properties.provided_timestamp), '')), NULL, if(and(in(ascii(toString(events.person_properties.provided_timestamp)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.provided_timestamp)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.provided_timestamp), '[]'), '{}'), toString(events.person_properties.provided_timestamp)))), 6, %(hogql_val_0)s) AS provided_timestamp
+ SELECT parseDateTime64BestEffortOrNull(if(notEquals(toJSONString(events.person_properties.^provided_timestamp), '{}'), toJSONString(events.person_properties.^provided_timestamp), if(isNull(events.person_properties.provided_timestamp), NULL, if(and(in(ascii(toString(events.person_properties.provided_timestamp)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.provided_timestamp)), tuple(91, 123))), toJSONString(events.person_properties.provided_timestamp), toString(events.person_properties.provided_timestamp)))), 6, %(hogql_val_0)s) AS provided_timestamp
FROM events_json AS events
WHERE equals(events.team_id, 420)
LIMIT 50000
diff --git a/posthog/hogql/transforms/test/__snapshots__/test_state_aggregations.new_events_schema.ambr b/posthog/hogql/transforms/test/__snapshots__/test_state_aggregations.new_events_schema.ambr
index 1a53660a4390..a9ca6c6fefc2 100644
--- a/posthog/hogql/transforms/test/__snapshots__/test_state_aggregations.new_events_schema.ambr
+++ b/posthog/hogql/transforms/test/__snapshots__/test_state_aggregations.new_events_schema.ambr
@@ -27,7 +27,7 @@
SELECT tuple(uniqMerge(tupleElement(comprehensive_metrics, 1)), countMerge(tupleElement(comprehensive_metrics, 2)), sumMerge(tupleElement(comprehensive_metrics, 3)), avgMerge(tupleElement(comprehensive_metrics, 4))) AS comprehensive_metrics, source AS source
FROM (
- SELECT tuple(uniqState(events.distinct_id), countStateIf(equals(events.event, %(hogql_val_0)s)), sumStateIf(1, equals(events.event, %(hogql_val_1)s)), avgStateIf(1, equals(events.event, %(hogql_val_2)s))) AS comprehensive_metrics, if(notEquals(toJSONString(events.properties.^campaign_source), '{}'), toJSONString(events.properties.^campaign_source), if(isNull(nullIf(toString(events.properties.campaign_source), '')), NULL, if(and(in(ascii(toString(events.properties.campaign_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.campaign_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.campaign_source), '[]'), '{}'), toString(events.properties.campaign_source)))) AS source
+ SELECT tuple(uniqState(events.distinct_id), countStateIf(equals(events.event, %(hogql_val_0)s)), sumStateIf(1, equals(events.event, %(hogql_val_1)s)), avgStateIf(1, equals(events.event, %(hogql_val_2)s))) AS comprehensive_metrics, if(notEquals(toJSONString(events.properties.^campaign_source), '{}'), toJSONString(events.properties.^campaign_source), if(isNull(events.properties.campaign_source), NULL, if(and(in(ascii(toString(events.properties.campaign_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.campaign_source)), tuple(91, 123))), toJSONString(events.properties.campaign_source), toString(events.properties.campaign_source)))) AS source
FROM events_json AS events
WHERE and(equals(events.team_id, 420), ifNull(equals(CAST(events.properties.campaign_source, 'Nullable(String)'), %(hogql_val_3)s), 0))
GROUP BY source)
@@ -35,7 +35,7 @@
LIMIT 50000 UNION ALL
SELECT tuple(uniqMerge(tupleElement(comprehensive_metrics, 1)), countMerge(tupleElement(comprehensive_metrics, 2)), sumMerge(tupleElement(comprehensive_metrics, 3)), avgMerge(tupleElement(comprehensive_metrics, 4))) AS comprehensive_metrics, source AS source
FROM (
- SELECT tuple(uniqState(events.distinct_id), countStateIf(equals(events.event, %(hogql_val_4)s)), sumStateIf(1, equals(events.event, %(hogql_val_5)s)), avgStateIf(1, equals(events.event, %(hogql_val_6)s))) AS comprehensive_metrics, if(notEquals(toJSONString(events.properties.^campaign_source), '{}'), toJSONString(events.properties.^campaign_source), if(isNull(nullIf(toString(events.properties.campaign_source), '')), NULL, if(and(in(ascii(toString(events.properties.campaign_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.campaign_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.campaign_source), '[]'), '{}'), toString(events.properties.campaign_source)))) AS source
+ SELECT tuple(uniqState(events.distinct_id), countStateIf(equals(events.event, %(hogql_val_4)s)), sumStateIf(1, equals(events.event, %(hogql_val_5)s)), avgStateIf(1, equals(events.event, %(hogql_val_6)s))) AS comprehensive_metrics, if(notEquals(toJSONString(events.properties.^campaign_source), '{}'), toJSONString(events.properties.^campaign_source), if(isNull(events.properties.campaign_source), NULL, if(and(in(ascii(toString(events.properties.campaign_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.campaign_source)), tuple(91, 123))), toJSONString(events.properties.campaign_source), toString(events.properties.campaign_source)))) AS source
FROM events_json AS events
WHERE and(equals(events.team_id, 420), ifNull(equals(CAST(events.properties.campaign_source, 'Nullable(String)'), %(hogql_val_7)s), 0))
GROUP BY source)
@@ -120,7 +120,7 @@
SELECT tuple(uniqMerge(tupleElement(user_metrics, 1)), countMerge(tupleElement(user_metrics, 2))) AS user_metrics, tuple(sumMerge(tupleElement(value_metrics, 1)), avgMerge(tupleElement(value_metrics, 2))) AS value_metrics, host AS host
FROM (
- SELECT tuple(uniqState(events.distinct_id), countState()) AS user_metrics, tuple(sumState(1), avgState(1)) AS value_metrics, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host
+ SELECT tuple(uniqState(events.distinct_id), countState()) AS user_metrics, tuple(sumState(1), avgState(1)) AS value_metrics, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host
FROM events_json AS events
WHERE and(equals(events.team_id, 420), less(events.timestamp, toDateTime64(%(hogql_val_0)s, 6, %(hogql_val_1)s)))
GROUP BY host)
@@ -128,7 +128,7 @@
LIMIT 50000 UNION ALL
SELECT tuple(uniqMerge(tupleElement(user_metrics, 1)), countMerge(tupleElement(user_metrics, 2))) AS user_metrics, tuple(sumMerge(tupleElement(value_metrics, 1)), avgMerge(tupleElement(value_metrics, 2))) AS value_metrics, host AS host
FROM (
- SELECT tuple(uniqState(events.distinct_id), countState()) AS user_metrics, tuple(sumState(1), avgState(1)) AS value_metrics, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host
+ SELECT tuple(uniqState(events.distinct_id), countState()) AS user_metrics, tuple(sumState(1), avgState(1)) AS value_metrics, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host
FROM events_json AS events
WHERE and(equals(events.team_id, 420), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_2)s, 6, %(hogql_val_3)s)), less(events.timestamp, toDateTime64(%(hogql_val_4)s, 6, %(hogql_val_5)s)))
GROUP BY host)
@@ -136,7 +136,7 @@
LIMIT 50000 UNION ALL
SELECT tuple(uniqMerge(tupleElement(user_metrics, 1)), countMerge(tupleElement(user_metrics, 2))) AS user_metrics, tuple(sumMerge(tupleElement(value_metrics, 1)), avgMerge(tupleElement(value_metrics, 2))) AS value_metrics, host AS host
FROM (
- SELECT tuple(uniqState(events.distinct_id), countState()) AS user_metrics, tuple(sumState(1), avgState(1)) AS value_metrics, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host
+ SELECT tuple(uniqState(events.distinct_id), countState()) AS user_metrics, tuple(sumState(1), avgState(1)) AS value_metrics, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host
FROM events_json AS events
WHERE and(equals(events.team_id, 420), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_6)s, 6, %(hogql_val_7)s)))
GROUP BY host)
@@ -219,7 +219,7 @@
SELECT uniqMerge(unique_users) AS unique_users, countMerge(total_events) AS total_events, host AS host
FROM (
- SELECT uniqState(events.distinct_id) AS unique_users, countState() AS total_events, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host
+ SELECT uniqState(events.distinct_id) AS unique_users, countState() AS total_events, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host
FROM events_json AS events
WHERE and(equals(events.team_id, 420), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_0)s, 6, %(hogql_val_1)s)))
GROUP BY host
@@ -277,7 +277,7 @@
SELECT host AS host, uniqMerge(unique_users) AS unique_users, sumMerge(click_count) AS click_count, avgMerge(avg_duration) AS avg_duration
FROM (
- SELECT if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host, uniqState(events.distinct_id) AS unique_users, sumStateIf(1, equals(events.event, %(hogql_val_0)s)) AS click_count, avgState(accurateCastOrNull(events.properties.session_duration, 'Float64')) AS avg_duration
+ SELECT if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host, uniqState(events.distinct_id) AS unique_users, sumStateIf(1, equals(events.event, %(hogql_val_0)s)) AS click_count, avgState(accurateCastOrNull(events.properties.session_duration, 'Float64')) AS avg_duration
FROM events_json AS events
WHERE equals(events.team_id, 420)
GROUP BY host)
@@ -304,7 +304,7 @@
# name: TestStateTransforms.test_preserve_group_by[new_events_schema]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS pathname, uniqState(events.distinct_id) AS unique_users, countState() AS total_events
+ SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS pathname, uniqState(events.distinct_id) AS unique_users, countState() AS total_events
FROM events_json AS events
WHERE and(equals(events.team_id, 420), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_0)s, 6, %(hogql_val_1)s)))
GROUP BY pathname
@@ -314,7 +314,7 @@
# name: TestStateTransforms.test_preserve_query_without_aggregations[new_events_schema]
'''
- SELECT events.distinct_id AS distinct_id, if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS pathname
+ SELECT events.distinct_id AS distinct_id, if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS pathname
FROM events_json AS events
WHERE and(equals(events.team_id, 420), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_0)s, 6, %(hogql_val_1)s)))
LIMIT 50000
@@ -465,7 +465,7 @@
SELECT tuple(uniqMerge(tupleElement(user_stats, 1)), countMerge(tupleElement(user_stats, 2))) AS user_stats, host AS host
FROM (
- SELECT tuple(uniqState(events.distinct_id), countState()) AS user_stats, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host
+ SELECT tuple(uniqState(events.distinct_id), countState()) AS user_stats, if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host
FROM events_json AS events
WHERE and(equals(events.team_id, 420), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_0)s, 6, %(hogql_val_1)s)))
GROUP BY host)
@@ -523,7 +523,7 @@
SELECT host AS host, countMerge(total_count) AS total_count, countMerge(click_count) AS click_count
FROM (
- SELECT if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))) AS host, countState() AS total_count, countStateIf(equals(events.event, %(hogql_val_0)s)) AS click_count
+ SELECT if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))) AS host, countState() AS total_count, countStateIf(equals(events.event, %(hogql_val_0)s)) AS click_count
FROM events_json AS events
WHERE equals(events.team_id, 420)
GROUP BY host)
diff --git a/posthog/hogql/transforms/test/test_clickhouse_property_resolution.py b/posthog/hogql/transforms/test/test_clickhouse_property_resolution.py
index 711a1d1a237f..fe87922f56cf 100644
--- a/posthog/hogql/transforms/test/test_clickhouse_property_resolution.py
+++ b/posthog/hogql/transforms/test/test_clickhouse_property_resolution.py
@@ -269,6 +269,8 @@ class TestNativeJSONPropertyComparisons(SimpleTestCase):
assert ("CAST(" in printed) is not declared
read = print_prepared_ast(clickhouse_property_resolution(prop, context), context, "clickhouse")
assert "JSONStripEmptyStringsAndNulls" not in read
+ has_key = ast.Call(name="JSONHas", args=[ast.Field(chain=[field], type=field_type), ast.Constant(value=key)])
+ has_key_sql = print_prepared_ast(clickhouse_property_resolution(has_key, context), context, "clickhouse")
fallback_values = ["", "[5]", '{"child":""}']
fallback = ast.Tuple(
exprs=[
@@ -303,7 +305,7 @@ class TestNativeJSONPropertyComparisons(SimpleTestCase):
)
)
rows = sync_execute(
- f"SELECT {printed}, {read}, {fallback_sql} FROM (SELECT CAST(arrayJoin(%(documents)s), %(json_type)s) AS {column}) AS events",
+ f"SELECT {printed}, {read}, {fallback_sql}, {has_key_sql} FROM (SELECT CAST(arrayJoin(%(documents)s), %(json_type)s) AS {column}) AS events",
{**context.values, "documents": [json.dumps(doc) for doc, _, _ in cases], "json_type": json_type},
settings={
"transform_null_in": 1,
@@ -312,12 +314,15 @@ class TestNativeJSONPropertyComparisons(SimpleTestCase):
},
)
assert [row[0] for row in rows] == [(eq, eq, 1 - eq, member, 1 - member, 1 - member) for _, eq, member in cases]
- for (_, read_value, fallback_result), (document, _, _) in zip(rows, cases):
+ for (_, read_value, fallback_result, has_key_result), (document, _, _) in zip(rows, cases):
assert fallback_result == tuple(int(read_value == value) for value in fallback_values)
sent = document.get(key)
- if sent in (None, "", [], {}):
+ # A declared String column stores a sent "" the same as a missing key, and ClickHouse's JSON type keeps
+ # no path for an empty object, so both read as missing.
+ if sent is None or sent == {} or (declared and sent == ""):
assert read_value is None
elif isinstance(sent, (list, dict)):
assert json.loads(read_value) == sent
else:
assert read_value == ("true" if sent is True else str(sent))
+ assert has_key_result == int(read_value is not None)
diff --git a/posthog/hogql/transforms/test/test_property_types.py b/posthog/hogql/transforms/test/test_property_types.py
index 8d34a6108752..1a3a72976ab6 100644
--- a/posthog/hogql/transforms/test/test_property_types.py
+++ b/posthog/hogql/transforms/test/test_property_types.py
@@ -1687,7 +1687,7 @@ class TestEventsSchemaStorageSemantics(ClickhouseTestMixin, HypothesisDjangoTest
value = properties["dynamic_value"]
encoded = json.dumps(value, ensure_ascii=False)
- assert native[0] == ((value or None) if isinstance(value, str) else encoded)
+ assert native[0] == (value if isinstance(value, str) else encoded)
assert legacy[0] == (encoded[1:-1] if isinstance(value, str) else encoded)
browser = properties.get("$browser")
diff --git a/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.new_events_schema.ambr b/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.new_events_schema.ambr
index 614eae23579a..bf97f497f806 100644
--- a/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.new_events_schema.ambr
+++ b/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.new_events_schema.ambr
@@ -58,10 +58,10 @@
count() AS value_count,
max(timestamp) AS latest_seen
FROM
- (SELECT [tuple('zero_duration_recording_count_in_period', JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^zero_duration_recording_count_in_period), '{}'), toJSONString(events.properties.^zero_duration_recording_count_in_period), if(isNull(nullIf(toString(events.properties.zero_duration_recording_count_in_period), '')), NULL, nullIf(nullIf(toJSONString(events.properties.zero_duration_recording_count_in_period), '[]'), '{}'))), '')))] AS kv,
+ (SELECT [tuple('zero_duration_recording_count_in_period', JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^zero_duration_recording_count_in_period), '{}'), toJSONString(events.properties.^zero_duration_recording_count_in_period), if(isNull(events.properties.zero_duration_recording_count_in_period), NULL, toJSONString(events.properties.zero_duration_recording_count_in_period))), '')))] AS kv,
toTimeZone(events.timestamp, 'UTC') AS timestamp
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64(minus(now64(6, 'UTC'), toIntervalDay(30)), 6, 'UTC')), equals(events.event, 'organization usage report'), notEquals(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^zero_duration_recording_count_in_period), '{}'), toJSONString(events.properties.^zero_duration_recording_count_in_period), if(isNull(nullIf(toString(events.properties.zero_duration_recording_count_in_period), '')), NULL, nullIf(nullIf(toJSONString(events.properties.zero_duration_recording_count_in_period), '[]'), '{}'))), '')), ''))) ARRAY
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64(minus(now64(6, 'UTC'), toIntervalDay(30)), 6, 'UTC')), equals(events.event, 'organization usage report'), notEquals(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^zero_duration_recording_count_in_period), '{}'), toJSONString(events.properties.^zero_duration_recording_count_in_period), if(isNull(events.properties.zero_duration_recording_count_in_period), NULL, toJSONString(events.properties.zero_duration_recording_count_in_period))), '')), ''))) ARRAY
JOIN (kv).1 AS key,
(kv).2 AS value
WHERE and(isNotNull(value), ifNull(notEquals(value, ''), 1))
diff --git a/posthog/hogql_queries/ai/test/__snapshots__/test_trace_query_runner.new_events_schema.ambr b/posthog/hogql_queries/ai/test/__snapshots__/test_trace_query_runner.new_events_schema.ambr
index 32cda686e7c6..2b8b32f91302 100644
--- a/posthog/hogql_queries/ai/test/__snapshots__/test_trace_query_runner.new_events_schema.ambr
+++ b/posthog/hogql_queries/ai/test/__snapshots__/test_trace_query_runner.new_events_schema.ambr
@@ -27,23 +27,23 @@
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(__ai_events_fallback.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(__ai_events_fallback.properties.`$feature_flags`), mapValues(__ai_events_fallback.properties.`$feature_flags`)), if(empty(__ai_events_fallback.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), __ai_events_fallback.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(__ai_events_fallback.temporary_properties)))), ','), '}') AS properties,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_trace_id`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_trace_id`)))) AS trace_id,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_session_id`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_session_id`)))) AS session_id,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_parent_id`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_parent_id`)))) AS parent_id,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_span_name`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_span_name`)))) AS span_name,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_trace_name`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_trace_name`)))) AS trace_name,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), if(isNull(__ai_events_fallback.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_trace_id`), toString(__ai_events_fallback.properties.`$ai_trace_id`)))) AS trace_id,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), if(isNull(__ai_events_fallback.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_session_id`), toString(__ai_events_fallback.properties.`$ai_session_id`)))) AS session_id,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), if(isNull(__ai_events_fallback.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_parent_id`), toString(__ai_events_fallback.properties.`$ai_parent_id`)))) AS parent_id,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), if(isNull(__ai_events_fallback.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_span_name`), toString(__ai_events_fallback.properties.`$ai_span_name`)))) AS span_name,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), if(isNull(__ai_events_fallback.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_trace_name`), toString(__ai_events_fallback.properties.`$ai_trace_name`)))) AS trace_name,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_latency`, 'Float64'), 'Float64') AS latency,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_input_tokens`, 'Float64'), 'Float64') AS input_tokens,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_output_tokens`, 'Float64'), 'Float64') AS output_tokens,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64') AS input_cost_usd,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_output_cost_usd`, 'Float64'), 'Float64') AS output_cost_usd,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_total_cost_usd`, 'Float64'), 'Float64') AS total_cost_usd,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_input`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_input`), '[]'), '{}'))), '')) AS input,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_output`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_output`), '[]'), '{}'))), '')) AS output,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_output_choices`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_output_choices`), '[]'), '{}'))), '')) AS output_choices,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_input_state`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_input_state`), '[]'), '{}'))), '')) AS input_state,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_output_state`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_output_state`), '[]'), '{}'))), '')) AS output_state,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_tools`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_tools`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_tools`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_tools`), '[]'), '{}'))), '')) AS tools
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input`), if(isNull(__ai_events_fallback.properties.`$ai_input`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_input`))), '')) AS input,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output`), if(isNull(__ai_events_fallback.properties.`$ai_output`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_output`))), '')) AS output,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), if(isNull(__ai_events_fallback.properties.`$ai_output_choices`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_output_choices`))), '')) AS output_choices,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), if(isNull(__ai_events_fallback.properties.`$ai_input_state`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_input_state`))), '')) AS input_state,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), if(isNull(__ai_events_fallback.properties.`$ai_output_state`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_output_state`))), '')) AS output_state,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_tools`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_tools`), if(isNull(__ai_events_fallback.properties.`$ai_tools`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_tools`))), '')) AS tools
FROM events_json AS __ai_events_fallback
WHERE and(equals(__ai_events_fallback.team_id, 99999), in(__ai_events_fallback.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(__ai_events_fallback.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(__ai_events_fallback.timestamp, assumeNotNull(toDateTime('2024-12-08 00:10:00', 'UTC'))), equals(CAST(__ai_events_fallback.properties.`$ai_trace_id`, 'Nullable(String)'), 'trace1'), ifNull(equals(CAST(__ai_events_fallback.properties.foo, 'Nullable(String)'), 'barz'), 0)))
LIMIT 1 BY __ai_events_fallback.uuid) AS deduped
@@ -92,23 +92,23 @@
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(__ai_events_fallback.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(__ai_events_fallback.properties.`$feature_flags`), mapValues(__ai_events_fallback.properties.`$feature_flags`)), if(empty(__ai_events_fallback.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), __ai_events_fallback.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(__ai_events_fallback.temporary_properties)))), ','), '}') AS properties,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_trace_id`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_trace_id`)))) AS trace_id,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_session_id`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_session_id`)))) AS session_id,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_parent_id`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_parent_id`)))) AS parent_id,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_span_name`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_span_name`)))) AS span_name,
- if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_trace_name`), '[]'), '{}'), toString(__ai_events_fallback.properties.`$ai_trace_name`)))) AS trace_name,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_id`), if(isNull(__ai_events_fallback.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_trace_id`), toString(__ai_events_fallback.properties.`$ai_trace_id`)))) AS trace_id,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_session_id`), if(isNull(__ai_events_fallback.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_session_id`), toString(__ai_events_fallback.properties.`$ai_session_id`)))) AS session_id,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_parent_id`), if(isNull(__ai_events_fallback.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_parent_id`), toString(__ai_events_fallback.properties.`$ai_parent_id`)))) AS parent_id,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_span_name`), if(isNull(__ai_events_fallback.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_span_name`), toString(__ai_events_fallback.properties.`$ai_span_name`)))) AS span_name,
+ if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_trace_name`), if(isNull(__ai_events_fallback.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(__ai_events_fallback.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(__ai_events_fallback.properties.`$ai_trace_name`), toString(__ai_events_fallback.properties.`$ai_trace_name`)))) AS trace_name,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_latency`, 'Float64'), 'Float64') AS latency,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_input_tokens`, 'Float64'), 'Float64') AS input_tokens,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_output_tokens`, 'Float64'), 'Float64') AS output_tokens,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64') AS input_cost_usd,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_output_cost_usd`, 'Float64'), 'Float64') AS output_cost_usd,
accurateCastOrNull(accurateCastOrNull(__ai_events_fallback.properties.`$ai_total_cost_usd`, 'Float64'), 'Float64') AS total_cost_usd,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_input`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_input`), '[]'), '{}'))), '')) AS input,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_output`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_output`), '[]'), '{}'))), '')) AS output,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_output_choices`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_output_choices`), '[]'), '{}'))), '')) AS output_choices,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_input_state`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_input_state`), '[]'), '{}'))), '')) AS input_state,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_output_state`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_output_state`), '[]'), '{}'))), '')) AS output_state,
- JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_tools`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_tools`), if(isNull(nullIf(toString(__ai_events_fallback.properties.`$ai_tools`), '')), NULL, nullIf(nullIf(toJSONString(__ai_events_fallback.properties.`$ai_tools`), '[]'), '{}'))), '')) AS tools
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input`), if(isNull(__ai_events_fallback.properties.`$ai_input`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_input`))), '')) AS input,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output`), if(isNull(__ai_events_fallback.properties.`$ai_output`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_output`))), '')) AS output,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_choices`), if(isNull(__ai_events_fallback.properties.`$ai_output_choices`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_output_choices`))), '')) AS output_choices,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_input_state`), if(isNull(__ai_events_fallback.properties.`$ai_input_state`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_input_state`))), '')) AS input_state,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_output_state`), if(isNull(__ai_events_fallback.properties.`$ai_output_state`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_output_state`))), '')) AS output_state,
+ JSONExtractRaw(ifNull(if(notEquals(toJSONString(__ai_events_fallback.properties.^`$ai_tools`), '{}'), toJSONString(__ai_events_fallback.properties.^`$ai_tools`), if(isNull(__ai_events_fallback.properties.`$ai_tools`), NULL, toJSONString(__ai_events_fallback.properties.`$ai_tools`))), '')) AS tools
FROM events_json AS __ai_events_fallback
WHERE and(equals(__ai_events_fallback.team_id, 99999), in(__ai_events_fallback.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(__ai_events_fallback.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(__ai_events_fallback.timestamp, assumeNotNull(toDateTime('2024-12-08 00:10:00', 'UTC'))), equals(CAST(__ai_events_fallback.properties.`$ai_trace_id`, 'Nullable(String)'), 'trace1'), ifNull(equals(CAST(__ai_events_fallback.person_properties.bar, 'Nullable(String)'), 'foo'), 0)))
LIMIT 1 BY __ai_events_fallback.uuid) AS deduped
diff --git a/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.new_events_schema.ambr b/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.new_events_schema.ambr
index 8e33070f06c7..967e6159dcad 100644
--- a/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.new_events_schema.ambr
+++ b/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.new_events_schema.ambr
@@ -1,12 +1,12 @@
# serializer version: 1
# name: TestTracesQueryRunner.test_field_mapping[new_events_schema.1]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -18,16 +18,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-13 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 01:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace1', 'trace2')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -52,11 +52,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -79,12 +79,12 @@
# ---
# name: TestTracesQueryRunner.test_group_key_filter[new_events_schema.1]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -96,16 +96,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-14 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 02:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_project_1', 'trace_org_b', 'trace_org_a')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -130,11 +130,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_0`, 'org:acme')))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_0`, 'org:acme')))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -157,12 +157,12 @@
# ---
# name: TestTracesQueryRunner.test_group_key_filter[new_events_schema.3]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -174,16 +174,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-14 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 00:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_org_a')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -208,11 +208,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_0`, 'org:widgets')))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_0`, 'org:widgets')))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -235,12 +235,12 @@
# ---
# name: TestTracesQueryRunner.test_group_key_filter[new_events_schema.5]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -252,16 +252,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 00:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 01:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_org_b')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -286,11 +286,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_1`, 'project:alpha')))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_1`, 'project:alpha')))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -313,12 +313,12 @@
# ---
# name: TestTracesQueryRunner.test_group_key_filter[new_events_schema.7]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -330,16 +330,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 01:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 02:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_project_1')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -364,11 +364,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_0`, 'nonexistent')))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC')))), equals(events.properties.`$group_0`, 'nonexistent')))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -395,11 +395,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -422,12 +422,12 @@
# ---
# name: TestTracesQueryRunner.test_pagination[new_events_schema.1]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -439,16 +439,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 05:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 10:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_10', 'trace_9', 'trace_8', 'trace_7', 'trace_6')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 5
OFFSET 0 SETTINGS readonly=2,
@@ -473,11 +473,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -500,12 +500,12 @@
# ---
# name: TestTracesQueryRunner.test_pagination[new_events_schema.3]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -517,16 +517,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 01:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 10:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_10', 'trace_9', 'trace_8', 'trace_7', 'trace_6', 'trace_5', 'trace_4', 'trace_3', 'trace_2')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 5
OFFSET 4 SETTINGS readonly=2,
@@ -551,11 +551,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -578,12 +578,12 @@
# ---
# name: TestTracesQueryRunner.test_pagination[new_events_schema.5]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -595,16 +595,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-14 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-15 10:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace_10', 'trace_9', 'trace_8', 'trace_7', 'trace_6', 'trace_5', 'trace_4', 'trace_3', 'trace_2', 'trace_1', 'trace_0')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 5
OFFSET 8 SETTINGS readonly=2,
@@ -629,11 +629,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-08 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2025-01-16 00:10:59', 'UTC'))))))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('today', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2025-01-09 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -656,12 +656,12 @@
# ---
# name: TestTracesQueryRunner.test_properties_filter_with_multiple_events_in_group[new_events_schema.1]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -673,16 +673,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace1')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -707,11 +707,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'baz'), 0)))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'baz'), 0)))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('2024-12-01 00:10:00.000000', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2024-12-01 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -734,12 +734,12 @@
# ---
# name: TestTracesQueryRunner.test_properties_filter_with_multiple_events_in_group[new_events_schema.3]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -751,16 +751,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:10:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace1')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -785,11 +785,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'barz'), 0)))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'barz'), 0)))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('2024-12-01 00:10:00.000000', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2024-12-01 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -816,11 +816,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'bar'), 0)))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'bar'), 0)))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('2024-12-01 00:10:00.000000', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2024-12-01 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -843,12 +843,12 @@
# ---
# name: TestTracesQueryRunner.test_trace_property_filter_for_event_group[new_events_schema.1]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -860,16 +860,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:55:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:15:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace1')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -894,11 +894,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'bar'), 0)))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'bar'), 0)))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('2024-12-01 00:10:00.000000', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2024-12-01 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -921,12 +921,12 @@
# ---
# name: TestTracesQueryRunner.test_trace_property_filter_for_event_group[new_events_schema.3]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS id,
- any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(nullIf(toString(events.properties.`$ai_session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_session_id`), '[]'), '{}'), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS id,
+ any(if(notEquals(toJSONString(events.properties.^`$ai_session_id`), '{}'), toJSONString(events.properties.^`$ai_session_id`), if(isNull(events.properties.`$ai_session_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_session_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_session_id`), toString(events.properties.`$ai_session_id`))))) AS ai_session_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS last_timestamp,
ifNull(nullIf(argMinIf(events.distinct_id, toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), ''), argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC'))) AS first_distinct_id,
- round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
+ round(coalesce(nullIf(maxIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_trace'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), 0), if(and(equals(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), notEquals(events.event, '$ai_generation'))), 0), greater(countIf(and(ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0), equals(events.event, '$ai_generation'))), 0)), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), and(equals(events.event, '$ai_generation'), ifNull(greater(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), 0), 0))), sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_latency`, 'Float64'), 'Float64'), or(isNull(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))), 2) AS total_latency,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS input_tokens,
sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_output_tokens`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))) AS output_tokens,
round(sumIf(accurateCastOrNull(accurateCastOrNull(events.properties.`$ai_input_cost_usd`, 'Float64'), 'Float64'), in(events.event, tuple('$ai_generation', '$ai_embedding'))), 10) AS input_cost,
@@ -938,16 +938,16 @@
and kv.1 in ('$exception_functions', '$exception_list', '$exception_sources', '$exception_types', '$exception_values', '$mcp_listed_tool_names'))
and not (kv.2 = '""'
and kv.1 in ('$browser', '$browser_language', '$browser_version', '$config_defaults', '$device_type', '$geoip_city_name', '$geoip_continent_code', '$geoip_continent_name', '$geoip_country_code', '$geoip_country_name', '$geoip_subdivision_1_name', '$geoip_time_zone', '$group_0', '$group_1', '$group_2', '$group_3', '$group_4', '$lib', '$lib_version', '$os', '$os_version', '$session_id', '$timezone', '$window_id'))
- and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(nullIf(toString(events.properties.`$ai_parent_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_parent_id`), '[]'), '{}'), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(nullIf(toString(events.properties.`$ai_input_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_input_state`), '[]'), '{}'), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
- argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(nullIf(toString(events.properties.`$ai_output_state`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_output_state`), '[]'), '{}'), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
- ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(nullIf(toString(events.properties.`$ai_span_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_span_name`), '[]'), '{}'), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(nullIf(toString(events.properties.`$ai_trace_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_name`), '[]'), '{}'), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
- countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(nullIf(toString(events.properties.`$ai_error`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_error`), '[]'), '{}'), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
- any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(nullIf(toString(events.properties.ai_support_impersonated), '')), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_support_impersonated), '[]'), '{}'), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
- arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
+ and kv.1 != '$feature_flags', JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), arrayConcat(arrayMap((key, value) -> concat(toJSONString(concat('$feature/', key)), ':', if(value in ('true', 'false'), value, toJSONString(multiIf(value = '$false', 'false', value = '$true', 'true', value)))), mapKeys(events.properties.`$feature_flags`), mapValues(events.properties.`$feature_flags`)), if(empty(events.properties.`$feature_flags`), [], [concat('"$active_feature_flags":', toJSONString(mapKeys(mapFilter((key, value) -> value not in ('', 'false'), events.properties.`$feature_flags`))))])), arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), JSONExtractKeysAndValuesRaw(toJSONString(events.temporary_properties)))), ','), '}')), or(in(events.event, tuple('$ai_metric', '$ai_feedback')), equals(toString(if(notEquals(toJSONString(events.properties.^`$ai_parent_id`), '{}'), toJSONString(events.properties.^`$ai_parent_id`), if(isNull(events.properties.`$ai_parent_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_parent_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_parent_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_parent_id`), toString(events.properties.`$ai_parent_id`))))), toString(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))))))))) AS events,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_input_state`), '{}'), toJSONString(events.properties.^`$ai_input_state`), if(isNull(events.properties.`$ai_input_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_input_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_input_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_input_state`), toString(events.properties.`$ai_input_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS input_state,
+ argMinIf(if(notEquals(toJSONString(events.properties.^`$ai_output_state`), '{}'), toJSONString(events.properties.^`$ai_output_state`), if(isNull(events.properties.`$ai_output_state`), NULL, if(and(in(ascii(toString(events.properties.`$ai_output_state`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_output_state`)), tuple(91, 123))), toJSONString(events.properties.`$ai_output_state`), toString(events.properties.`$ai_output_state`)))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')) AS output_state,
+ ifNull(argMinIf(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'), equals(events.event, '$ai_trace')), argMin(ifNull(if(notEquals(toJSONString(events.properties.^`$ai_span_name`), '{}'), toJSONString(events.properties.^`$ai_span_name`), if(isNull(events.properties.`$ai_span_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_span_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_span_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_span_name`), toString(events.properties.`$ai_span_name`)))), if(notEquals(toJSONString(events.properties.^`$ai_trace_name`), '{}'), toJSONString(events.properties.^`$ai_trace_name`), if(isNull(events.properties.`$ai_trace_name`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_name`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_name`), toString(events.properties.`$ai_trace_name`))))), toTimeZone(events.timestamp, 'UTC'))) AS trace_name,
+ countIf(or(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_error`), '{}'), toJSONString(events.properties.^`$ai_error`), if(isNull(events.properties.`$ai_error`), NULL, if(and(in(ascii(toString(events.properties.`$ai_error`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_error`)), tuple(91, 123))), toJSONString(events.properties.`$ai_error`), toString(events.properties.`$ai_error`))))), equals(CAST(events.properties.`$ai_is_error`, 'Nullable(String)'), 'true'))) AS error_count,
+ any(if(notEquals(toJSONString(events.properties.^ai_support_impersonated), '{}'), toJSONString(events.properties.^ai_support_impersonated), if(isNull(events.properties.ai_support_impersonated), NULL, if(and(in(ascii(toString(events.properties.ai_support_impersonated)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_support_impersonated)), tuple(91, 123))), toJSONString(events.properties.ai_support_impersonated), toString(events.properties.ai_support_impersonated))))) AS is_support_trace,
+ arrayFilter(x -> ifNull(notEquals(x, ''), 1), arrayDistinct(splitByChar(',', arrayStringConcat(groupArrayIf(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), and(equals(events.event, '$ai_generation'), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ifNull(notEquals(toString(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`))))), ''), 1))), ',')))) AS tools
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:52:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:12:00', 'UTC'))))), in(CAST(events.properties.`$ai_trace_id`, 'Nullable(String)'), tuple('trace1')))
- GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))
+ GROUP BY if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))
ORDER BY first_timestamp DESC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
@@ -972,11 +972,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), and(ifNull(equals(CAST(events.properties.`$ai_span_name`, 'Nullable(String)'), 'runnable'), 0), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'bar'), 0))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), and(ifNull(equals(CAST(events.properties.`$ai_span_name`, 'Nullable(String)'), 'runnable'), 0), ifNull(equals(CAST(events.properties.foo, 'Nullable(String)'), 'bar'), 0))))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('2024-12-01 00:10:00.000000', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2024-12-01 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
@@ -1003,11 +1003,11 @@
min(first_ts) AS min_timestamp,
max(last_ts) AS max_timestamp
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))) AS trace_id,
min(toTimeZone(events.timestamp, 'UTC')) AS first_ts,
max(toTimeZone(events.timestamp, 'UTC')) AS last_ts
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(nullIf(toString(events.properties.`$ai_trace_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_trace_id`), '[]'), '{}'), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.`$ai_span_name`, 'Nullable(String)'), 'runnable'), 0)))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace')), and(isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`))))), notEquals(if(notEquals(toJSONString(events.properties.^`$ai_trace_id`), '{}'), toJSONString(events.properties.^`$ai_trace_id`), if(isNull(events.properties.`$ai_trace_id`), NULL, if(and(in(ascii(toString(events.properties.`$ai_trace_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_trace_id`)), tuple(91, 123))), toJSONString(events.properties.`$ai_trace_id`), toString(events.properties.`$ai_trace_id`)))), ''), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-11-30 23:50:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-12-01 00:20:00', 'UTC')))), ifNull(equals(CAST(events.properties.`$ai_span_name`, 'Nullable(String)'), 'runnable'), 0)))
GROUP BY trace_id
HAVING and(lessOrEquals(min(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime64('2024-12-01 00:10:00.000000', 6, 'UTC'))), greaterOrEquals(max(toTimeZone(events.timestamp, 'UTC')), assumeNotNull(toDateTime('2024-12-01 00:00:00', 'UTC'))))
ORDER BY min(toTimeZone(events.timestamp, 'UTC')) DESC
diff --git a/posthog/hogql_queries/ai/test/test_traces_query_runner.py b/posthog/hogql_queries/ai/test/test_traces_query_runner.py
index d62df6f2fa7b..ff145d50324f 100644
--- a/posthog/hogql_queries/ai/test/test_traces_query_runner.py
+++ b/posthog/hogql_queries/ai/test/test_traces_query_runner.py
@@ -8,8 +8,6 @@ import time_machine
from posthog.test.base import BaseTest, ClickhouseTestMixin, _create_event, _create_person, snapshot_clickhouse_queries
from unittest.mock import patch
-from django.conf import settings
-
from parameterized import parameterized
from posthog.schema import (
@@ -1174,9 +1172,7 @@ class TestTracesQueryRunner(ClickhouseTestMixin, BaseTest):
),
).calculate()
- # The native-JSON table treats an empty value as absent, so an explicit '' never matches there.
- expected_ids = set() if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else {"trace_with_empty_name"}
- self.assertEqual({result.id for result in response.results}, expected_ids)
+ self.assertEqual({result.id for result in response.results}, {"trace_with_empty_name"})
@snapshot_clickhouse_queries
def test_properties_filter_with_multiple_events_in_group(self):
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
index 90f6793f8223..030cc0b7b23f 100644
--- 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
@@ -87,7 +87,7 @@
# ---
# 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(nullIf(toString(events.properties.idx), '')), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.idx), '[]'), '{}'), toString(events.properties.idx)))) AS idx,
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), 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), globalIn(events.uuid,
@@ -116,7 +116,7 @@
# ---
# 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(nullIf(toString(events.properties.idx), '')), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.idx), '[]'), '{}'), toString(events.properties.idx)))) AS idx,
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), 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), globalIn(events.uuid,
@@ -145,7 +145,7 @@
# ---
# name: TestEventsQueryRunner.test_cursor_pagination_multi_page_asc[new_events_schema]
'''
- SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(nullIf(toString(events.properties.idx), '')), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.idx), '[]'), '{}'), toString(events.properties.idx)))) AS idx,
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), 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), globalIn(events.uuid,
@@ -174,7 +174,7 @@
# ---
# 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(nullIf(toString(events.properties.idx), '')), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.idx), '[]'), '{}'), toString(events.properties.idx)))) AS idx,
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), 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), globalIn(events.uuid,
@@ -203,7 +203,7 @@
# ---
# 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(nullIf(toString(events.properties.idx), '')), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.idx), '[]'), '{}'), toString(events.properties.idx)))) AS idx,
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), 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), globalIn(events.uuid,
@@ -232,7 +232,7 @@
# ---
# name: TestEventsQueryRunner.test_cursor_pagination_multi_page_desc[new_events_schema]
'''
- SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(nullIf(toString(events.properties.idx), '')), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.idx), '[]'), '{}'), toString(events.properties.idx)))) AS idx,
+ SELECT if(notEquals(toJSONString(events.properties.^idx), '{}'), toJSONString(events.properties.^idx), if(isNull(events.properties.idx), NULL, if(and(in(ascii(toString(events.properties.idx)), tuple(91, 123)), in(ascii(toJSONString(events.properties.idx)), tuple(91, 123))), 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), globalIn(events.uuid,
@@ -432,9 +432,9 @@
(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(nullIf(toString(events.properties.priority), '')), NULL, if(and(in(ascii(toString(events.properties.priority)), tuple(91, 123)), in(ascii(toJSONString(events.properties.priority)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.priority), '[]'), '{}'), toString(events.properties.priority)))) ASC
+ ORDER BY if(notEquals(toJSONString(events.properties.^priority), '{}'), toJSONString(events.properties.^priority), if(isNull(events.properties.priority), NULL, if(and(in(ascii(toString(events.properties.priority)), tuple(91, 123)), in(ascii(toJSONString(events.properties.priority)), tuple(91, 123))), 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(nullIf(toString(events.properties.priority), '')), NULL, if(and(in(ascii(toString(events.properties.priority)), tuple(91, 123)), in(ascii(toJSONString(events.properties.priority)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.priority), '[]'), '{}'), toString(events.properties.priority)))) ASC
+ ORDER BY if(notEquals(toJSONString(events.properties.^priority), '{}'), toJSONString(events.properties.^priority), if(isNull(events.properties.priority), NULL, if(and(in(ascii(toString(events.properties.priority)), tuple(91, 123)), in(ascii(toJSONString(events.properties.priority)), tuple(91, 123))), toJSONString(events.properties.priority), toString(events.properties.priority)))) ASC
LIMIT 101
OFFSET 0 SETTINGS readonly=2,
max_execution_time=60,
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
index 882438ecaf42..86f408ea2943 100644
--- 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
@@ -26,7 +26,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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^something), '{}'), toJSONString(events.properties.^something), if(isNull(nullIf(toString(events.properties.something), '')), NULL, if(and(in(ascii(toString(events.properties.something)), tuple(91, 123)), in(ascii(toJSONString(events.properties.something)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.something), '[]'), '{}'), toString(events.properties.something))))), '%paul.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^something), '{}'), toJSONString(events.properties.^something), if(isNull(events.properties.something), NULL, if(and(in(ascii(toString(events.properties.something)), tuple(91, 123)), in(ascii(toJSONString(events.properties.something)), tuple(91, 123))), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -76,7 +76,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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '^(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(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -379,7 +379,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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^something), '{}'), toJSONString(events.properties.^something), if(isNull(nullIf(toString(events.properties.something), '')), NULL, if(and(in(ascii(toString(events.properties.something)), tuple(91, 123)), in(ascii(toJSONString(events.properties.something)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.something), '[]'), '{}'), toString(events.properties.something))))), '%paul.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^something), '{}'), toJSONString(events.properties.^something), if(isNull(events.properties.something), NULL, if(and(in(ascii(toString(events.properties.something)), tuple(91, 123)), in(ascii(toJSONString(events.properties.something)), tuple(91, 123))), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -429,7 +429,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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '^(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(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
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
index a291ec7c29a2..cfb0b3a27260 100644
--- 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
@@ -3116,17 +3116,17 @@
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(equals(CAST(events.properties.is_internal_user, 'Nullable(String)'), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
+ HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), equals(events.properties.`$browser`, 'Chrome'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
+ HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
LIMIT 1000000)), globalNotIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -3284,7 +3284,7 @@
WHERE and(equals(s.team_id, 99999), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -4240,7 +4240,7 @@
LIMIT 1000000)), globalNotIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '^(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(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -6431,17 +6431,17 @@
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(equals(CAST(events.properties.is_internal_user, 'Nullable(String)'), 'false'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
+ HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), equals(events.properties.`$browser`, 'Chrome'), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
+ HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 0)), 0)
LIMIT 1000000)), globalNotIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2021-01-17 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -6599,7 +6599,7 @@
WHERE and(equals(s.team_id, 99999), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%gmail.com%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
@@ -7555,7 +7555,7 @@
LIMIT 1000000)), globalNotIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '^(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(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)))
GROUP BY s.session_id
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
index 080ff442d73c..5052acac63cb 100644
--- 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
@@ -32,7 +32,7 @@
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
HAVING 1
LIMIT 1000000))))
@@ -89,7 +89,7 @@
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
HAVING 1
LIMIT 1000000))))
@@ -140,20 +140,20 @@
WHERE and(equals(s.team_id, 99999), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)), and(globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.vip, 'Nullable(String)'), 'true'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0)
+ HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0)
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0)
+ HAVING equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0)
LIMIT 1000000))))
GROUP BY s.session_id
HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 0))
@@ -208,7 +208,7 @@
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
HAVING 1
LIMIT 1000000))))
@@ -259,20 +259,20 @@
WHERE and(equals(s.team_id, 99999), 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 if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), or(ifNull(equals(CAST(events.properties.vip, 'Nullable(String)'), 'true'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), or(ifNull(equals(CAST(events.properties.vip, 'Nullable(String)'), 'true'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
LIMIT 1000000)), and(globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notEquals(CAST(events.properties.vip, 'Nullable(String)'), 'true'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING and(equals(countIf(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(nullIf(toString(events.properties.vip), '')), NULL, if(and(in(ascii(toString(events.properties.vip)), tuple(91, 123)), in(ascii(toJSONString(events.properties.vip)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.vip), '[]'), '{}'), toString(events.properties.vip)))), 'true'), 0)), 0), equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0))
+ HAVING and(equals(countIf(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(and(in(ascii(toString(events.properties.vip)), tuple(91, 123)), in(ascii(toJSONString(events.properties.vip)), tuple(91, 123))), toJSONString(events.properties.vip), toString(events.properties.vip)))), 'true'), 0)), 0), equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0))
LIMIT 1000000)), globalIn(s.session_id,
(SELECT if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), notEmpty(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))), lessOrEquals(events.timestamp, toDateTime64(now64(6, 'UTC'), 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 1)), greaterOrEquals(events.timestamp, toDateTime64('2020-12-28 00:00:00.000000', 6, 'UTC')))
GROUP BY if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`))))
- HAVING and(equals(countIf(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(nullIf(toString(events.properties.vip), '')), NULL, if(and(in(ascii(toString(events.properties.vip)), tuple(91, 123)), in(ascii(toJSONString(events.properties.vip)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.vip), '[]'), '{}'), toString(events.properties.vip)))), 'true'), 0)), 0), equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0))
+ HAVING and(equals(countIf(ifNull(equals(if(notEquals(toJSONString(events.properties.^vip), '{}'), toJSONString(events.properties.^vip), if(isNull(events.properties.vip), NULL, if(and(in(ascii(toString(events.properties.vip)), tuple(91, 123)), in(ascii(toJSONString(events.properties.vip)), tuple(91, 123))), toJSONString(events.properties.vip), toString(events.properties.vip)))), 'true'), 0)), 0), equals(countIf(ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '%target%'), 0)), 0))
LIMIT 1000000))))
GROUP BY s.session_id
HAVING and(greaterOrEquals(expiry_time, toDateTime64('today', 6, 'UTC')), equals(max(s.is_deleted), 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
index 58b5389398cc..e272ca360ef4 100644
--- 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
@@ -1,10 +1,10 @@
# serializer version: 1
# name: TestStopSurveysReachedTarget.test_stop_surveys_with_enough_responses[new_events_schema.1]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(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(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`)))), toString(events.uuid))) AS unique_responses
+ SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(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(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), 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(if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(events.properties.`$survey_id`)))), ['00000000-0000-0000-0000-000000000003']))
+ WHERE and(equals(events.team_id, 99999), equals(events.event, 'survey sent'), greaterOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), in(if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(events.properties.`$survey_id`)))), ['00000000-0000-0000-0000-000000000003']))
GROUP BY survey_id
LIMIT 1 SETTINGS readonly=2,
max_execution_time=60,
@@ -24,10 +24,10 @@
# ---
# name: TestStopSurveysReachedTarget.test_stop_surveys_with_enough_responses[new_events_schema]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(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(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(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(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`)))), toString(events.uuid))) AS unique_responses
+ SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(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(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), 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(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), 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(if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(events.properties.`$survey_id`)))), ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']))
+ 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(if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(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,
diff --git a/products/ai_observability/backend/api/test/__snapshots__/test_personal_spend.new_events_schema.ambr b/products/ai_observability/backend/api/test/__snapshots__/test_personal_spend.new_events_schema.ambr
index 9bc31bb700fb..60f7e8ad546a 100644
--- a/products/ai_observability/backend/api/test/__snapshots__/test_personal_spend.new_events_schema.ambr
+++ b/products/ai_observability/backend/api/test/__snapshots__/test_personal_spend.new_events_schema.ambr
@@ -2,7 +2,7 @@
# name: TestPersonalSpendQueries.test_empty_result_when_no_events[new_events_schema.1]
'''
/* user_id:0 request:_snapshot_@me_spend_ */
- SELECT nullIf(arrayJoin(splitByChar(',', coalesce(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(nullIf(toString(events.properties.`$ai_tools_called`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_tools_called`), '[]'), '{}'), toString(events.properties.`$ai_tools_called`)))), ''))), '') AS tool,
+ SELECT nullIf(arrayJoin(splitByChar(',', coalesce(if(notEquals(toJSONString(events.properties.^`$ai_tools_called`), '{}'), toJSONString(events.properties.^`$ai_tools_called`), if(isNull(events.properties.`$ai_tools_called`), NULL, if(and(in(ascii(toString(events.properties.`$ai_tools_called`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_tools_called`)), tuple(91, 123))), toJSONString(events.properties.`$ai_tools_called`), toString(events.properties.`$ai_tools_called`)))), ''))), '') AS tool,
count() AS generation_count,
round(sum(accurateCastOrNull(events.properties.`$ai_total_cost_usd`, 'Float64')), 6) AS cost_usd,
round(avg(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64')), 0) AS avg_input_tokens
@@ -29,7 +29,7 @@
# name: TestPersonalSpendQueries.test_empty_result_when_no_events[new_events_schema.2]
'''
/* user_id:0 request:_snapshot_@me_spend_ */
- SELECT if(notEquals(toJSONString(events.properties.^ai_product), '{}'), toJSONString(events.properties.^ai_product), if(isNull(nullIf(toString(events.properties.ai_product), '')), NULL, if(and(in(ascii(toString(events.properties.ai_product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_product)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.ai_product), '[]'), '{}'), toString(events.properties.ai_product)))) AS product,
+ SELECT if(notEquals(toJSONString(events.properties.^ai_product), '{}'), toJSONString(events.properties.^ai_product), if(isNull(events.properties.ai_product), NULL, if(and(in(ascii(toString(events.properties.ai_product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.ai_product)), tuple(91, 123))), toJSONString(events.properties.ai_product), toString(events.properties.ai_product)))) AS product,
count() AS event_count,
round(sum(accurateCastOrNull(events.properties.`$ai_total_cost_usd`, 'Float64')), 6) AS cost_usd
FROM events_json AS events
@@ -55,7 +55,7 @@
# name: TestPersonalSpendQueries.test_empty_result_when_no_events[new_events_schema.3]
'''
/* user_id:0 request:_snapshot_@me_spend_ */
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_model`), '{}'), toJSONString(events.properties.^`$ai_model`), if(isNull(nullIf(toString(events.properties.`$ai_model`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_model`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_model`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_model`), '[]'), '{}'), toString(events.properties.`$ai_model`)))) AS model,
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_model`), '{}'), toJSONString(events.properties.^`$ai_model`), if(isNull(events.properties.`$ai_model`), NULL, if(and(in(ascii(toString(events.properties.`$ai_model`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_model`)), tuple(91, 123))), toJSONString(events.properties.`$ai_model`), toString(events.properties.`$ai_model`)))) AS model,
count() AS generation_count,
round(sum(accurateCastOrNull(events.properties.`$ai_total_cost_usd`, 'Float64')), 6) AS cost_usd,
sum(accurateCastOrNull(events.properties.`$ai_input_tokens`, 'Float64')) AS input_tokens,
@@ -111,9 +111,9 @@
# name: TestPersonalSpendQueries.test_empty_result_when_no_events[new_events_schema.5]
'''
/* user_id:0 request:_snapshot_@me_spend_ */
- SELECT if(notEquals(toJSONString(events.properties.^`$ai_model`), '{}'), toJSONString(events.properties.^`$ai_model`), if(isNull(nullIf(toString(events.properties.`$ai_model`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_model`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_model`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_model`), '[]'), '{}'), toString(events.properties.`$ai_model`)))) AS model
+ SELECT if(notEquals(toJSONString(events.properties.^`$ai_model`), '{}'), toJSONString(events.properties.^`$ai_model`), if(isNull(events.properties.`$ai_model`), NULL, if(and(in(ascii(toString(events.properties.`$ai_model`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_model`)), tuple(91, 123))), toJSONString(events.properties.`$ai_model`), toString(events.properties.`$ai_model`)))) AS model
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_generation', '$ai_embedding')), ifNull(equals(CAST(events.properties.ai_product, 'Nullable(String)'), 'posthog_code'), 0), ifNull(equals(CAST(events.person_properties.email, 'Nullable(String)'), '[email protected]'), 0), and(greaterOrEquals(events.timestamp, toDateTime64('2025-12-16 12:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('today', 6, 'UTC'))), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_model`), '{}'), toJSONString(events.properties.^`$ai_model`), if(isNull(nullIf(toString(events.properties.`$ai_model`), '')), NULL, if(and(in(ascii(toString(events.properties.`$ai_model`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_model`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$ai_model`), '[]'), '{}'), toString(events.properties.`$ai_model`))))))
+ WHERE and(equals(events.team_id, 99999), in(events.event, tuple('$ai_generation', '$ai_embedding')), ifNull(equals(CAST(events.properties.ai_product, 'Nullable(String)'), 'posthog_code'), 0), ifNull(equals(CAST(events.person_properties.email, 'Nullable(String)'), '[email protected]'), 0), and(greaterOrEquals(events.timestamp, toDateTime64('2025-12-16 12:00:00.000000', 6, 'UTC')), less(events.timestamp, toDateTime64('today', 6, 'UTC'))), isNotNull(if(notEquals(toJSONString(events.properties.^`$ai_model`), '{}'), toJSONString(events.properties.^`$ai_model`), if(isNull(events.properties.`$ai_model`), NULL, if(and(in(ascii(toString(events.properties.`$ai_model`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$ai_model`)), tuple(91, 123))), toJSONString(events.properties.`$ai_model`), toString(events.properties.`$ai_model`))))))
GROUP BY model
ORDER BY sum(accurateCastOrNull(events.properties.`$ai_total_cost_usd`, 'Float64')) DESC, model ASC
LIMIT 6 SETTINGS readonly=2,
diff --git a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_breakdowns_query_runner.new_events_schema.ambr b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_breakdowns_query_runner.new_events_schema.ambr
index 713273c1dba2..9ab3cea8d98e 100644
--- a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_breakdowns_query_runner.new_events_schema.ambr
+++ b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_breakdowns_query_runner.new_events_schema.ambr
@@ -29,7 +29,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2024-01-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.event, '$exception'), ifNull(equals(events__fingerprint_issue_state.issue_id, '01936e7f-d7ff-7314-b2d4-7627981e34f0'), 0))))
GROUP BY breakdown_property,
breakdown_value))
@@ -82,7 +82,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2024-01-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.event, '$exception'), ifNull(equals(events__fingerprint_issue_state.issue_id, '01936e7f-d7ff-7314-b2d4-7627981e34f0'), 0))))
GROUP BY breakdown_property,
breakdown_value))
@@ -135,7 +135,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2024-01-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.event, '$exception'), ifNull(equals(events__fingerprint_issue_state.issue_id, '01936e7f-d7ff-7314-b2d4-7627981e34f0'), 0))))
GROUP BY breakdown_property,
breakdown_value))
@@ -188,7 +188,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, toDateTime64('2024-01-03 00:00:00.000000', 6, 'UTC')), lessOrEquals(events.timestamp, toDateTime64('today', 6, 'UTC')), equals(events.event, '$exception'), ifNull(equals(events__fingerprint_issue_state.issue_id, '01936e7f-d7ff-7314-b2d4-7627981e34f0'), 0))))
GROUP BY breakdown_property,
breakdown_value))
diff --git a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_issue_correlation_query_runner.new_events_schema.ambr b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_issue_correlation_query_runner.new_events_schema.ambr
index 0c169b15b1a4..8830e0dd5602 100644
--- a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_issue_correlation_query_runner.new_events_schema.ambr
+++ b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_issue_correlation_query_runner.new_events_schema.ambr
@@ -16,7 +16,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64(minus(now64(6, 'UTC'), toIntervalHour(6)), 6, 'UTC')), notEmpty(events.properties.`$session_id`), isNotNull(events__fingerprint_issue_state.issue_id), equals(events.event, '$exception'))
GROUP BY events__fingerprint_issue_state.issue_id))
SELECT event AS event,
@@ -56,7 +56,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(events.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$exception_fingerprint`), '[]'), '{}'), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(events.properties.^`$exception_fingerprint`), '{}'), toJSONString(events.properties.^`$exception_fingerprint`), if(isNull(events.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(events.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(events.properties.`$exception_fingerprint`), toString(events.properties.`$exception_fingerprint`))))), events__fingerprint_issue_state.fp_hash)
WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64(minus(now64(6, 'UTC'), toIntervalHour(6)), 6, 'UTC')), notEmpty(events.properties.`$session_id`))
GROUP BY events.properties.`$session_id`) ARRAY
JOIN events AS event,
diff --git a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.new_events_schema.ambr b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.new_events_schema.ambr
index f266808aaed5..8d1c882ecb97 100644
--- a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.new_events_schema.ambr
+++ b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.new_events_schema.ambr
@@ -19,7 +19,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 1))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -29,7 +29,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -87,7 +87,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 1))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -97,7 +97,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -150,13 +150,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['probs']), 0), 0)), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['not']), 0), 0)), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['found']), 0), 0))))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['probs']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['probs']), 0), 0)), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['not']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['not']), 0), 0)), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['found']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['found']), 0), 0))))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -221,7 +221,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), e__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), e__fingerprint_issue_state.fp_hash)
WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(e__fingerprint_issue_state.issue_id), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2016-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), in(e__fingerprint_issue_state.issue_id,
(SELECT posthog__error_tracking_fingerprint_issue_state.issue_id AS issue_id
FROM
@@ -280,7 +280,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), e__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), e__fingerprint_issue_state.fp_hash)
WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(e__fingerprint_issue_state.issue_id), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2016-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), in(e__fingerprint_issue_state.issue_id,
(SELECT posthog__error_tracking_fingerprint_issue_state.issue_id AS issue_id
FROM
@@ -326,13 +326,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_0`, 'org:widgets'))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_0`, 'org:widgets'))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -384,13 +384,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_1`, 'project:alpha'))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_1`, 'project:alpha'))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -442,13 +442,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_0`, 'nonexistent'))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_0`, 'nonexistent'))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -500,13 +500,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_0`, 'org:acme'))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(e.properties.`$group_0`, 'org:acme'))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -558,13 +558,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), ifNull(equals(CAST(e.person_properties.email, 'Nullable(String)'), '[email protected]'), 0))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), ifNull(equals(CAST(e.person_properties.email, 'Nullable(String)'), '[email protected]'), 0))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -629,7 +629,7 @@
FROM error_tracking_fingerprint_issue_state
WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999)
GROUP BY fp_hash
- HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), e__fingerprint_issue_state.fp_hash)
+ HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__fingerprint_issue_state ON equals(cityHash64(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), e__fingerprint_issue_state.fp_hash)
WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(e__fingerprint_issue_state.issue_id), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), ifNull(equals(e__fingerprint_issue_state.issue_name, 'TypeError'), 0))
GROUP BY id
ORDER BY last_seen DESC,
@@ -671,7 +671,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 1))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -681,7 +681,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -734,13 +734,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2016-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2016-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -792,13 +792,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -851,13 +851,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -914,7 +914,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 1))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -924,7 +924,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -978,7 +978,7 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -991,7 +991,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 e__override ON equals(e.distinct_id, e__override.distinct_id)
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), '00000000-0000-4000-8000-000000000002'))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), '00000000-0000-4000-8000-000000000002'))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -1043,13 +1043,13 @@
argMaxMerge(ev.source_state) AS source,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
argMaxState(if(notEquals(toJSONString(e.properties.^`$lib`), '{}'), toJSONString(e.properties.^`$lib`), if(isNull(nullIf(toString(e.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(e.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$lib`), '[]'), '{}'), toString(e.properties.`$lib`)))), toTimeZone(e.timestamp, 'UTC')) AS library_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['[email protected]']), 0), 0)))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['[email protected]']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['[email protected]']), 0), 0)))
GROUP BY fp_hash) AS ev
INNER JOIN
(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,
@@ -1106,7 +1106,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 1))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -1116,7 +1116,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['databasenot']), 0), 0)))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenot']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['databasenot']), 0), 0)))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -1174,7 +1174,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 1))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -1184,7 +1184,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['databasenotfoundX']), 0), 0)), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(nullIf(toString(e.properties.email), '')), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.email), '[]'), '{}'), toString(e.properties.email))))), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), ['clickhouse/client/execute.py']), 0), 0))))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['databasenotfoundX']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['databasenotfoundX']), 0), 0)), or(arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_types`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_values`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_sources`, []), 'Array(String)')), arrayExists(v -> ifNull(greater(multiSearchAnyCaseInsensitive(v, ['clickhouse/client/execute.py']), 0), 0), accurateCast(ifNull(e.properties.`$exception_functions`, []), 'Array(String)')), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.properties.^email), '{}'), toJSONString(e.properties.^email), if(isNull(e.properties.email), NULL, if(and(in(ascii(toString(e.properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.properties.email)), tuple(91, 123))), toJSONString(e.properties.email), toString(e.properties.email))))), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), ['clickhouse/client/execute.py']), 0), 0))))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -1242,7 +1242,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 4))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -1252,7 +1252,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
@@ -1310,7 +1310,7 @@
and isNull(i)), ev.occ, toUInt64(0)), range(0, 3))) AS volumeRange,
argMaxMerge(ev.library_state) AS library
FROM
- (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'))), ''))) AS fp_hash,
+ (SELECT cityHash64(JSONExtractString(ifNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, toJSONString(e.properties.`$exception_fingerprint`))), ''))) AS fp_hash,
max(toTimeZone(e.timestamp, 'UTC')) AS last_seen_fp,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_functions`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_functions`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_functions`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_functions`[-1]), '[]'), '{}'), toString(e.properties.`$exception_functions`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS function_state,
argMaxState(if(isNull(nullIf(toString(e.properties.`$exception_sources`[-1]), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_sources`[-1])), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_sources`[-1])), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_sources`[-1]), '[]'), '{}'), toString(e.properties.`$exception_sources`[-1]))), toTimeZone(e.timestamp, 'UTC')) AS source_state,
@@ -1320,7 +1320,7 @@
uniqState(nullIf(e.properties.`$session_id`, '')) AS sessions_state,
uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_state
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(nullIf(toString(e.properties.`$exception_fingerprint`), '')), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$exception_fingerprint`), '[]'), '{}'), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(if(notEquals(toJSONString(e.properties.^`$exception_fingerprint`), '{}'), toJSONString(e.properties.^`$exception_fingerprint`), if(isNull(e.properties.`$exception_fingerprint`), NULL, if(and(in(ascii(toString(e.properties.`$exception_fingerprint`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$exception_fingerprint`)), tuple(91, 123))), toJSONString(e.properties.`$exception_fingerprint`), toString(e.properties.`$exception_fingerprint`))))), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2020-01-10 00:00:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')))
GROUP BY fp_hash,
bin_idx) AS ev
INNER JOIN
diff --git a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_actors_query.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_actors_query.new_events_schema.ambr
index c61eedad0853..bbf6ebeba783 100644
--- a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_actors_query.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_actors_query.new_events_schema.ambr
@@ -7,7 +7,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -20,7 +20,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id) SELECT exposures.entity_id AS actor_id,
exposures.variant AS variant,
array(tuple(toTimeZone(exposures.first_exposure_time, 'UTC'), exposures.exposure_event_uuid, exposures.exposure_session_id, '')) AS matching_events,
@@ -55,7 +55,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -68,7 +68,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id) SELECT exposures.entity_id AS actor_id,
exposures.variant AS variant,
actor_id AS id
@@ -102,7 +102,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -115,7 +115,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id) SELECT exposures.entity_id AS actor_id,
exposures.variant AS variant,
actor_id AS id
@@ -149,7 +149,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -162,7 +162,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -223,7 +223,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -236,7 +236,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -297,7 +297,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -310,7 +310,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -371,7 +371,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -384,7 +384,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -445,7 +445,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -458,7 +458,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -519,7 +519,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -532,7 +532,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -593,7 +593,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -606,7 +606,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -667,7 +667,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -680,7 +680,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -741,7 +741,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -754,7 +754,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -815,7 +815,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -828,7 +828,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -890,7 +890,7 @@
FROM
(WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -903,7 +903,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_activation_config.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_activation_config.new_events_schema.ambr
index 77df5df15fba..b43ae00e8d7c 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_activation_config.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_activation_config.new_events_schema.ambr
@@ -15,7 +15,7 @@
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
INNER JOIN
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_flag_exposure_time
FROM events_json AS events
LEFT OUTER JOIN
@@ -25,9 +25,9 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id) AS flag_exposures ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), flag_exposures.entity_id)
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), greaterOrEquals(events.timestamp, toDateTime64(flag_exposures.first_flag_exposure_time, 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), greaterOrEquals(events.timestamp, toDateTime64(flag_exposures.first_flag_exposure_time, 6, 'UTC')))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -72,7 +72,7 @@
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
INNER JOIN
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_flag_exposure_time
FROM events_json AS events
LEFT OUTER JOIN
@@ -82,16 +82,16 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id) AS flag_exposures ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), flag_exposures.entity_id)
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), greaterOrEquals(events.timestamp, toDateTime64(flag_exposures.first_flag_exposure_time, 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), greaterOrEquals(events.timestamp, toDateTime64(flag_exposures.first_flag_exposure_time, 6, 'UTC')))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)) AS step_0,
if(equals(events.event, 'purchase'), 1, 0) AS step_1
FROM events_json AS events
LEFT OUTER JOIN
@@ -101,7 +101,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
entity_metrics AS
(SELECT exposures.entity_id AS entity_id,
exposures.variant AS variant,
@@ -153,7 +153,7 @@
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
INNER JOIN
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_flag_exposure_time
FROM events_json AS events
LEFT OUTER JOIN
@@ -163,9 +163,9 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id) AS flag_exposures ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), flag_exposures.entity_id)
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), greaterOrEquals(events.timestamp, toDateTime64(flag_exposures.first_flag_exposure_time, 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), equals(events.event, 'activated'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)), greaterOrEquals(events.timestamp, toDateTime64(flag_exposures.first_flag_exposure_time, 6, 'UTC')))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_base.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_base.new_events_schema.ambr
index d7bdc62cc7bb..82692273eba5 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_base.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_base.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -16,12 +16,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
- if(notEquals(toJSONString(events.properties.^margin), '{}'), toJSONString(events.properties.^margin), if(isNull(nullIf(toString(events.properties.margin), '')), NULL, if(and(in(ascii(toString(events.properties.margin)), tuple(91, 123)), in(ascii(toJSONString(events.properties.margin)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.margin), '[]'), '{}'), toString(events.properties.margin)))) AS value
+ if(notEquals(toJSONString(events.properties.^margin), '{}'), toJSONString(events.properties.^margin), if(isNull(events.properties.margin), NULL, if(and(in(ascii(toString(events.properties.margin)), tuple(91, 123)), in(ascii(toJSONString(events.properties.margin)), tuple(91, 123))), toJSONString(events.properties.margin), toString(events.properties.margin)))) AS value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -67,7 +67,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -80,7 +80,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -131,13 +131,13 @@
'''
WITH exposures AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
GROUP BY entity_id),
metric_events AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
@@ -181,13 +181,13 @@
'''
WITH exposures AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
GROUP BY entity_id),
metric_events AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
@@ -231,7 +231,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -244,7 +244,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-02-01 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-02-01 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -295,7 +295,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -308,7 +308,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -359,7 +359,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -372,7 +372,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -423,7 +423,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), toTimeZone(events.timestamp, 'UTC')) AS variant,
+ argMin(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), toTimeZone(events.timestamp, 'UTC')) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -436,7 +436,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -487,7 +487,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -500,7 +500,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -551,7 +551,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -564,7 +564,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -615,7 +615,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -628,7 +628,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -679,7 +679,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -692,7 +692,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -743,7 +743,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -756,7 +756,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -820,7 +820,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(equals(events.event, 'purchase'), ifNull(equals(CAST(events.properties.plan, 'Nullable(String)'), 'premium'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(equals(events.event, 'purchase'), ifNull(equals(CAST(events.properties.plan, 'Nullable(String)'), 'premium'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -884,7 +884,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(equals(events.event, '$pageview'), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(equals(events.event, '$pageview'), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -935,7 +935,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -948,7 +948,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1012,7 +1012,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), equals(events.event, '$pageview'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1063,7 +1063,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1076,12 +1076,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
- if(notEquals(toJSONString(events.properties.^amount), '{}'), toJSONString(events.properties.^amount), if(isNull(nullIf(toString(events.properties.amount), '')), NULL, if(and(in(ascii(toString(events.properties.amount)), tuple(91, 123)), in(ascii(toJSONString(events.properties.amount)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.amount), '[]'), '{}'), toString(events.properties.amount)))) AS value
+ if(notEquals(toJSONString(events.properties.^amount), '{}'), toJSONString(events.properties.^amount), if(isNull(events.properties.amount), NULL, if(and(in(ascii(toString(events.properties.amount)), tuple(91, 123)), in(ascii(toJSONString(events.properties.amount)), tuple(91, 123))), toJSONString(events.properties.amount), toString(events.properties.amount)))) AS value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1127,7 +1127,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1140,7 +1140,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1191,7 +1191,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1204,12 +1204,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
- if(notEquals(toJSONString(events.properties.^price), '{}'), toJSONString(events.properties.^price), if(isNull(nullIf(toString(events.properties.price), '')), NULL, if(and(in(ascii(toString(events.properties.price)), tuple(91, 123)), in(ascii(toJSONString(events.properties.price)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.price), '[]'), '{}'), toString(events.properties.price)))) AS value
+ if(notEquals(toJSONString(events.properties.^price), '{}'), toJSONString(events.properties.^price), if(isNull(events.properties.price), NULL, if(and(in(ascii(toString(events.properties.price)), tuple(91, 123)), in(ascii(toJSONString(events.properties.price)), tuple(91, 123))), toJSONString(events.properties.price), toString(events.properties.price)))) AS value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1255,7 +1255,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1268,7 +1268,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1319,7 +1319,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1332,7 +1332,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1383,7 +1383,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1396,7 +1396,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1447,7 +1447,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1460,7 +1460,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(not(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '^(localhost|127\\.0\\.0\\.1)($|:)')), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(not(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))), '^(localhost|127\\.0\\.0\\.1)($|:)')), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1511,7 +1511,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1524,7 +1524,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1575,7 +1575,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1588,7 +1588,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(has(events.properties.`$feature_flags`, 'flag_doesnt_exist'), multiIf(ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$true'), 0), 'true', events.properties.`$feature_flags`['flag_doesnt_exist']), NULL), tuple('test', 'control')), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(has(events.properties.`$feature_flags`, 'flag_doesnt_exist'), multiIf(ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$true'), 0), 'true', events.properties.`$feature_flags`['flag_doesnt_exist']), NULL), tuple('test', 'control')), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1639,7 +1639,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1652,7 +1652,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1703,7 +1703,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1719,7 +1719,7 @@
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
(SELECT person_static_cohort.person_id AS person_id
FROM person_static_cohort
- WHERE and(equals(person_static_cohort.team_id, 99999), equals(person_static_cohort.cohort_id, 99999)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(person_static_cohort.team_id, 99999), equals(person_static_cohort.cohort_id, 99999)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1770,7 +1770,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1783,7 +1783,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1834,7 +1834,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1850,7 +1850,7 @@
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
(SELECT cohortpeople.person_id AS person_id
FROM cohortpeople
- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1901,7 +1901,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1914,7 +1914,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1965,7 +1965,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1986,7 +1986,7 @@
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.properties.`$group_0`, events__group_0.key)
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(equals(events__group_0.properties___name, 'Test Group'), 0), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(equals(events__group_0.properties___name, 'Test Group'), 0), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2037,7 +2037,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2050,7 +2050,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2101,7 +2101,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2114,7 +2114,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2165,7 +2165,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2178,7 +2178,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2229,7 +2229,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2242,7 +2242,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2293,7 +2293,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2306,7 +2306,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2357,7 +2357,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2370,7 +2370,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2421,7 +2421,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2434,7 +2434,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-05 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2485,13 +2485,13 @@
'''
WITH exposures AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
GROUP BY entity_id),
metric_events AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
@@ -2535,7 +2535,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2548,7 +2548,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -2599,7 +2599,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -2612,7 +2612,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-02-01 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-02-01 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_breakdown.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_breakdown.new_events_schema.ambr
index 312480cc8783..a2e676dadc6a 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_breakdown.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_breakdown.new_events_schema.ambr
@@ -3,11 +3,11 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
coalesce(toString(if(notEquals(toJSONString(events.properties.^`$browser`), '{}'), toJSONString(events.properties.^`$browser`), if(isNull(nullIf(toString(events.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(events.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$browser`), '[]'), '{}'), toString(events.properties.`$browser`))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, 'purchase'), 1, 0) AS step_1
FROM events_json AS events
LEFT OUTER JOIN
@@ -17,7 +17,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -56,11 +56,11 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -71,7 +71,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC')), toIntervalSecond(1209600)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC')), toIntervalSecond(1209600)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -110,12 +110,12 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
coalesce(toString(if(notEquals(toJSONString(events.properties.^`$browser`), '{}'), toJSONString(events.properties.^`$browser`), if(isNull(nullIf(toString(events.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(events.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$browser`), '[]'), '{}'), toString(events.properties.`$browser`))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
coalesce(toString(if(notEquals(toJSONString(events.properties.^`$os`), '{}'), toJSONString(events.properties.^`$os`), if(isNull(nullIf(toString(events.properties.`$os`), '')), NULL, if(and(in(ascii(toString(events.properties.`$os`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$os`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$os`), '[]'), '{}'), toString(events.properties.`$os`))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_2,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, 'purchase'), 1, 0) AS step_1
FROM events_json AS events
LEFT OUTER JOIN
@@ -125,7 +125,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -167,7 +167,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -181,7 +181,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -237,7 +237,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -251,7 +251,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -307,7 +307,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -321,7 +321,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -377,12 +377,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
+ argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -391,13 +391,13 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
coalesce(accurateCastOrNull(events.properties.amount, 'Float64'), 0) AS value,
- coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -447,13 +447,13 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
argMin(coalesce(toString(if(notEquals(toJSONString(events.properties.^`$browser`), '{}'), toJSONString(events.properties.^`$browser`), if(isNull(nullIf(toString(events.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(events.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$browser`), '[]'), '{}'), toString(events.properties.`$browser`))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1,
- argMin(coalesce(toString(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_2
+ argMin(coalesce(toString(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_2
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -462,14 +462,14 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
coalesce(accurateCastOrNull(events.properties.amount, 'Float64'), 0) AS value,
coalesce(toString(if(notEquals(toJSONString(events.properties.^`$browser`), '{}'), toJSONString(events.properties.^`$browser`), if(isNull(nullIf(toString(events.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(events.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$browser`), '[]'), '{}'), toString(events.properties.`$browser`))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
- coalesce(toString(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_2
+ coalesce(toString(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_2
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -523,12 +523,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
+ argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -537,13 +537,13 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
coalesce(accurateCastOrNull(events.properties.amount, 'Float64'), 0) AS value,
- coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -593,7 +593,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -608,7 +608,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -669,7 +669,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -683,7 +683,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -752,7 +752,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -767,7 +767,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -828,12 +828,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
+ argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -842,13 +842,13 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
coalesce(accurateCastOrNull(events.properties.amount, 'Float64'), 0) AS value,
- coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -898,7 +898,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -912,7 +912,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -997,12 +997,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
+ argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1011,7 +1011,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1096,7 +1096,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1111,7 +1111,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -1200,7 +1200,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1214,7 +1214,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1287,12 +1287,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(nullIf(toString(events.person_properties.country), '')), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.country), '[]'), '{}'), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
+ argMin(coalesce(toString(if(notEquals(toJSONString(events.person_properties.^country), '{}'), toJSONString(events.person_properties.^country), if(isNull(events.person_properties.country), NULL, if(and(in(ascii(toString(events.person_properties.country)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.country)), tuple(91, 123))), toJSONString(events.person_properties.country), toString(events.person_properties.country))))), '$$_posthog_breakdown_null_$$'), toTimeZone(events.timestamp, 'UTC')) AS breakdown_value_1
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1301,7 +1301,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1374,7 +1374,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1389,7 +1389,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_data_warehouse_metric.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_data_warehouse_metric.new_events_schema.ambr
index f7c0a82b0f1d..4bd0b64fced6 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_data_warehouse_metric.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_data_warehouse_metric.new_events_schema.ambr
@@ -3,12 +3,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -17,7 +17,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -62,13 +62,13 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_num,
- argMin(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_denom
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_num,
+ argMin(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_denom
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -77,7 +77,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -151,12 +151,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -165,7 +165,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -210,12 +210,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -224,7 +224,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -269,12 +269,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -283,7 +283,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -328,12 +328,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -342,7 +342,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -387,12 +387,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -401,7 +401,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -446,12 +446,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -460,7 +460,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -505,12 +505,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -519,7 +519,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -564,14 +564,14 @@
'''
WITH exposures AS
(SELECT events.properties.`$group_0` AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
argMin(events.distinct_id, toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(events.properties.`$group_0`))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(events.properties.`$group_0`))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -616,12 +616,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -630,7 +630,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -675,12 +675,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -689,7 +689,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -734,12 +734,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -748,7 +748,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -793,12 +793,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -807,7 +807,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(not(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '^(localhost|127\\.0\\.0\\.1)($|:)')), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(not(match(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))), '^(localhost|127\\.0\\.0\\.1)($|:)')), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -852,12 +852,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -866,7 +866,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -911,12 +911,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -925,7 +925,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(has(events.properties.`$feature_flags`, 'flag_doesnt_exist'), multiIf(ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$true'), 0), 'true', events.properties.`$feature_flags`['flag_doesnt_exist']), NULL), tuple('test', 'control')), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(has(events.properties.`$feature_flags`, 'flag_doesnt_exist'), multiIf(ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['flag_doesnt_exist'], '$true'), 0), 'true', events.properties.`$feature_flags`['flag_doesnt_exist']), NULL), tuple('test', 'control')), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -970,12 +970,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -984,7 +984,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1029,12 +1029,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1046,7 +1046,7 @@
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
(SELECT person_static_cohort.person_id AS person_id
FROM person_static_cohort
- WHERE and(equals(person_static_cohort.team_id, 99999), equals(person_static_cohort.cohort_id, 99999)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(person_static_cohort.team_id, 99999), equals(person_static_cohort.cohort_id, 99999)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1091,12 +1091,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1105,7 +1105,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1150,12 +1150,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1167,7 +1167,7 @@
WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
(SELECT cohortpeople.person_id AS person_id
FROM cohortpeople
- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999), equals(cohortpeople.version, 0)))), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1212,12 +1212,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1226,7 +1226,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1271,12 +1271,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1293,7 +1293,7 @@
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.properties.`$group_0`, events__group_0.key)
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(equals(events__group_0.properties___name, 'Test Group'), 0), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(equals(events__group_0.properties___name, 'Test Group'), 0), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1338,12 +1338,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1352,7 +1352,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1397,12 +1397,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1411,7 +1411,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_usage.userid AS entity_id,
@@ -1456,12 +1456,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1470,7 +1470,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT posthog_test_stripe_subscriptions__subscription_customer.customer_email AS entity_id,
@@ -1521,13 +1521,13 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_num,
- argMin(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_denom
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_num,
+ argMin(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier_denom
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1536,7 +1536,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT posthog_test_usage.userid AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_experiment_exposures_query_runner.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_experiment_exposures_query_runner.new_events_schema.ambr
index c9d7ae4c1d68..e378b5512e43 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_experiment_exposures_query_runner.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_experiment_exposures_query_runner.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -13,7 +13,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -43,7 +43,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -53,7 +53,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -83,7 +83,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -93,7 +93,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -123,7 +123,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), toTimeZone(events.timestamp, 'UTC')) AS variant,
+ argMin(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), toTimeZone(events.timestamp, 'UTC')) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -133,7 +133,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -163,7 +163,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -173,7 +173,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -203,10 +203,10 @@
'''
WITH first_exposures AS
(SELECT if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-28 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-28 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(if(less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('today', 6, 'UTC')), '', events.properties.`$group_0`)))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -246,7 +246,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(equals(events.event, 'purchase'), ifNull(equals(CAST(events.properties.plan, 'Nullable(String)'), 'premium'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(equals(events.event, 'purchase'), ifNull(equals(CAST(events.properties.plan, 'Nullable(String)'), 'premium'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -286,7 +286,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(equals(events.event, '$pageview'), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(equals(events.event, '$pageview'), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -316,7 +316,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -326,7 +326,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(notEquals(CAST(events.properties.plan, 'Nullable(String)'), 'free'), 1)), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -356,7 +356,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -366,7 +366,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
@@ -396,7 +396,7 @@
'''
WITH first_exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
toDateOrNull(toString(min(toTimeZone(events.timestamp, 'UTC')))) AS day
FROM events_json AS events
LEFT OUTER JOIN
@@ -406,7 +406,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-07 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id)
SELECT first_exposures.day AS day,
first_exposures.variant AS variant,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_frequentist_method.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_frequentist_method.new_events_schema.ambr
index b8422e80d094..6da7d3beeb20 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_frequentist_method.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_frequentist_method.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -16,7 +16,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_funnel_metric.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_funnel_metric.new_events_schema.ambr
index 0978c3bc3e63..c2f655c17f63 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_funnel_metric.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_funnel_metric.new_events_schema.ambr
@@ -3,10 +3,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -17,7 +17,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -53,10 +53,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -67,7 +67,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
first_exposures AS
(SELECT base_events.entity_id AS entity_id,
min(toTimeZone(base_events.timestamp, 'UTC')) AS first_exposure_time
@@ -110,10 +110,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'experiment-flag'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'experiment-flag'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -124,7 +124,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'experiment-flag'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'experiment-flag'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -160,10 +160,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, 'purchase'), 1, 0) AS step_1
FROM events_json AS events
LEFT OUTER JOIN
@@ -173,7 +173,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-02 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-02 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-10 00:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-02 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-02 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-10 00:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -209,10 +209,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -223,7 +223,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
first_exposures AS
(SELECT base_events.entity_id AS entity_id,
min(toTimeZone(base_events.timestamp, 'UTC')) AS first_exposure_time
@@ -266,10 +266,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -280,7 +280,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -316,10 +316,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -330,7 +330,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -366,10 +366,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -380,7 +380,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -416,10 +416,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -430,7 +430,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC')), toIntervalSecond(86400)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC')), toIntervalSecond(86400)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -466,10 +466,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'add to cart'), 1, 0) AS step_2,
if(equals(events.event, 'checkout started'), 1, 0) AS step_3,
@@ -484,7 +484,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'add to cart'), equals(events.event, 'checkout started'), equals(events.event, 'checkout completed'), equals(events.event, 'survey submitted'), equals(events.event, 'referral')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'add to cart'), equals(events.event, 'checkout started'), equals(events.event, 'checkout completed'), equals(events.event, 'survey submitted'), equals(events.event, 'referral')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -520,10 +520,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2,
if(equals(events.event, 'purchase'), 1, 0) AS step_3
@@ -535,7 +535,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -571,10 +571,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.wizard_step, 'Nullable(String)'), 'step_1'), 0)), 1, 0) AS step_1,
if(and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.wizard_step, 'Nullable(String)'), 'step_2'), 0)), 1, 0) AS step_2
FROM events_json AS events
@@ -585,7 +585,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.wizard_step, 'Nullable(String)'), 'step_1'), 0)), and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.wizard_step, 'Nullable(String)'), 'step_2'), 0))))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.wizard_step, 'Nullable(String)'), 'step_1'), 0)), and(equals(events.event, '$pageview'), ifNull(equals(CAST(events.properties.wizard_step, 'Nullable(String)'), 'step_2'), 0))))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -621,10 +621,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -635,7 +635,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
first_exposures AS
(SELECT base_events.entity_id AS entity_id,
min(toTimeZone(base_events.timestamp, 'UTC')) AS first_exposure_time
@@ -678,10 +678,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -692,7 +692,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC')), toIntervalSecond(604800)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC')), toIntervalSecond(604800)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -728,10 +728,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
if(equals(events.event, 'purchase'), 1, 0) AS step_2
FROM events_json AS events
@@ -742,7 +742,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC')), toIntervalSecond(604800)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, toDateTime64(plus(assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC')), toIntervalSecond(604800)), 6, 'UTC')), or(equals(events.event, '$pageview'), equals(events.event, 'purchase')))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -778,12 +778,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -792,19 +792,19 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
- (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`))))) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant,
+ (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`))))) AS entity_id,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id,
- if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
+ if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
0 AS step_2
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
UNION ALL SELECT toString(posthog_test_usage.userid) AS entity_id,
'' AS variant,
posthog_test_usage.ds AS timestamp,
@@ -852,12 +852,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -866,19 +866,19 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
- (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`))))) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant,
+ (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`))))) AS entity_id,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id,
- if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
+ if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
0 AS step_2
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
UNION ALL SELECT toString(posthog_test_usage.userid) AS entity_id,
'' AS variant,
posthog_test_usage.ds AS timestamp,
@@ -926,12 +926,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -940,19 +940,19 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
- (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`))))) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant,
+ (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`))))) AS entity_id,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id,
- if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
+ if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
0 AS step_2
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
UNION ALL SELECT toString(posthog_test_usage.userid) AS entity_id,
'' AS variant,
posthog_test_usage.ds AS timestamp,
@@ -1000,12 +1000,12 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
argMin(events.properties.`$session_id`, toTimeZone(events.timestamp, 'UTC')) AS exposure_session_id,
- argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
+ argMin(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`)))), toTimeZone(events.timestamp, 'UTC')) AS exposure_identifier
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1014,19 +1014,19 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
- (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(nullIf(toString(events.properties.`$user_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_id`), '[]'), '{}'), toString(events.properties.`$user_id`))))) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant,
+ (SELECT toString(if(notEquals(toJSONString(events.properties.^`$user_id`), '{}'), toJSONString(events.properties.^`$user_id`), if(isNull(events.properties.`$user_id`), NULL, if(and(in(ascii(toString(events.properties.`$user_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_id`)), tuple(91, 123))), toJSONString(events.properties.`$user_id`), toString(events.properties.`$user_id`))))) AS entity_id,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))) AS session_id,
- if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
+ if(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), 1, 0) AS step_0,
if(equals(events.event, '$pageview'), 1, 0) AS step_1,
0 AS step_2
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), less(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC')))), or(and(greaterOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-01 00:00:00', 'UTC'))), lessOrEquals(timestamp, assumeNotNull(toDateTime('2023-01-31 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), equals(events.event, '$pageview')))
UNION ALL SELECT toString(posthog_test_usage.userid) AS entity_id,
'' AS variant,
posthog_test_usage.ds AS timestamp,
@@ -1074,10 +1074,10 @@
'''
WITH base_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])) AS step_0,
if(equals(events.event, 'purchase'), 1, 0) AS step_1
FROM events_json AS events
LEFT OUTER JOIN
@@ -1087,7 +1087,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), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test'])), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
@@ -1123,13 +1123,13 @@
'''
WITH base_events AS
(SELECT events.properties.`$group_0` AS entity_id,
- if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
+ if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))) AS variant_value,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
events.uuid AS uuid,
- and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(events.properties.`$group_0`)) AS step_0,
+ and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(events.properties.`$group_0`)) AS step_0,
if(equals(events.event, 'purchase'), 1, 0) AS step_1
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(events.properties.`$group_0`)), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
+ WHERE and(equals(events.team_id, 99999), or(and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']), notEmpty(events.properties.`$group_0`)), and(greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'purchase'))))),
entity_metrics AS
(SELECT base_events.entity_id AS entity_id,
if(greater(uniqExactIf(base_events.variant_value, equals(base_events.step_0, 1)), 1), '$multiple', anyIf(base_events.variant_value, equals(base_events.step_0, 1))) AS variant,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_mean_metric.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_mean_metric.new_events_schema.ambr
index 7495d68e3648..b6c468eae8c6 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_mean_metric.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_mean_metric.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -16,7 +16,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -67,7 +67,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -80,12 +80,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
- if(notEquals(toJSONString(events.properties.^category), '{}'), toJSONString(events.properties.^category), if(isNull(nullIf(toString(events.properties.category), '')), NULL, if(and(in(ascii(toString(events.properties.category)), tuple(91, 123)), in(ascii(toJSONString(events.properties.category)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.category), '[]'), '{}'), toString(events.properties.category)))) AS value
+ if(notEquals(toJSONString(events.properties.^category), '{}'), toJSONString(events.properties.^category), if(isNull(events.properties.category), NULL, if(and(in(ascii(toString(events.properties.category)), tuple(91, 123)), in(ascii(toJSONString(events.properties.category)), tuple(91, 123))), toJSONString(events.properties.category), toString(events.properties.category)))) AS value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -131,7 +131,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -144,12 +144,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
- if(notEquals(toJSONString(events.properties.^category), '{}'), toJSONString(events.properties.^category), if(isNull(nullIf(toString(events.properties.category), '')), NULL, if(and(in(ascii(toString(events.properties.category)), tuple(91, 123)), in(ascii(toJSONString(events.properties.category)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.category), '[]'), '{}'), toString(events.properties.category)))) AS value
+ if(notEquals(toJSONString(events.properties.^category), '{}'), toJSONString(events.properties.^category), if(isNull(events.properties.category), NULL, if(and(in(ascii(toString(events.properties.category)), tuple(91, 123)), in(ascii(toJSONString(events.properties.category)), tuple(91, 123))), toJSONString(events.properties.category), toString(events.properties.category)))) AS value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -205,7 +205,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -218,7 +218,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id
HAVING lessOrEquals(plus(min(toTimeZone(events.timestamp, 'UTC')), toIntervalSecond(604800)), parseDateTime64BestEffortOrNull('2020-01-15 12:00:00', 6, 'UTC'))),
metric_events AS
@@ -270,7 +270,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -283,7 +283,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -344,7 +344,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -357,7 +357,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -418,7 +418,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -431,7 +431,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -492,7 +492,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -505,7 +505,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -556,7 +556,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -569,7 +569,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -620,7 +620,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -633,7 +633,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -684,7 +684,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -697,7 +697,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -748,7 +748,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -761,7 +761,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -812,7 +812,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -825,7 +825,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_ratio_metric.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_ratio_metric.new_events_schema.ambr
index 168f60071dc9..096d28fbeb61 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_ratio_metric.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_ratio_metric.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -16,7 +16,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -185,7 +185,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -198,7 +198,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id
HAVING lessOrEquals(plus(min(toTimeZone(events.timestamp, 'UTC')), toIntervalSecond(604800)), parseDateTime64BestEffortOrNull('2020-01-15 12:00:00', 6, 'UTC'))),
numerator_events AS
@@ -280,7 +280,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -293,7 +293,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -387,7 +387,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -400,7 +400,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -494,7 +494,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -508,7 +508,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -609,7 +609,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -622,7 +622,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -703,7 +703,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -716,7 +716,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -797,7 +797,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -810,7 +810,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -891,7 +891,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -904,7 +904,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
@@ -985,7 +985,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -998,12 +998,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-10 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
- if(notEquals(toJSONString(events.properties.^amount), '{}'), toJSONString(events.properties.^amount), if(isNull(nullIf(toString(events.properties.amount), '')), NULL, if(and(in(ascii(toString(events.properties.amount)), tuple(91, 123)), in(ascii(toJSONString(events.properties.amount)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.amount), '[]'), '{}'), toString(events.properties.amount)))) AS value
+ if(notEquals(toJSONString(events.properties.^amount), '{}'), toJSONString(events.properties.^amount), if(isNull(events.properties.amount), NULL, if(and(in(ascii(toString(events.properties.amount)), tuple(91, 123)), in(ascii(toJSONString(events.properties.amount)), tuple(91, 123))), toJSONString(events.properties.amount), toString(events.properties.amount)))) AS value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1079,7 +1079,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1092,7 +1092,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
numerator_events AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_retention_metric.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_retention_metric.new_events_schema.ambr
index f5c57e1fb4cb..f81393aab6a5 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_retention_metric.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_retention_metric.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -16,7 +16,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -85,7 +85,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -98,7 +98,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -168,7 +168,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -181,7 +181,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -264,7 +264,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), equals(events.event, 'entered_experiment'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), equals(events.event, 'entered_experiment'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -324,7 +324,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -337,7 +337,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-25 00:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -420,7 +420,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'entered_experiment'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'entered_experiment'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -480,7 +480,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -493,7 +493,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -575,7 +575,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'entered_experiment'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(events.event, 'entered_experiment'), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(has(events.properties.`$feature_flags`, 'test-experiment'), multiIf(ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', ifNull(equals(events.properties.`$feature_flags`['test-experiment'], '$true'), 0), 'true', events.properties.`$feature_flags`['test-experiment']), NULL), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -635,7 +635,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -648,7 +648,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(equals(events.event, '$feature_flag_called'), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(equals(events.event, '$feature_flag_called'), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -708,7 +708,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -721,7 +721,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -790,7 +790,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -803,7 +803,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -872,7 +872,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -885,7 +885,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -954,7 +954,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -967,7 +967,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1036,7 +1036,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1049,7 +1049,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment-3-variants'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test_a', 'test_b']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment-3-variants'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test_a', 'test_b']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1118,7 +1118,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1131,7 +1131,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1200,7 +1200,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1213,7 +1213,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1282,7 +1282,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1295,7 +1295,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
@@ -1364,7 +1364,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -1377,7 +1377,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
start_events AS
(SELECT exposures.entity_id AS entity_id,
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_session_properties.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_session_properties.new_events_schema.ambr
index 1d759230c500..cdf9179e4e6a 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_session_properties.new_events_schema.ambr
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/__snapshots__/test_session_properties.new_events_schema.ambr
@@ -3,7 +3,7 @@
'''
WITH exposures AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
- if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))))) AS variant,
+ if(greater(uniqExact(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`))))), 1), '$multiple', any(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))))) AS variant,
min(toTimeZone(events.timestamp, 'UTC')) AS first_exposure_time,
max(toTimeZone(events.timestamp, 'UTC')) AS last_exposure_time,
argMin(events.uuid, toTimeZone(events.timestamp, 'UTC')) AS exposure_event_uuid,
@@ -16,7 +16,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), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(nullIf(toString(events.properties.`$feature_flag_response`), '')), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$feature_flag_response`), '[]'), '{}'), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
+ WHERE and(equals(events.team_id, 99999), greaterOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-01 12:00:00', 'UTC'))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2024-01-15 12:00:00', 'UTC'))), and(in(events.event, ['$feature_flag_called', '$experiment_exposure']), ifNull(equals(CAST(events.properties.`$feature_flag`, 'Nullable(String)'), 'test-experiment'), 0)), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1), in(if(notEquals(toJSONString(events.properties.^`$feature_flag_response`), '{}'), toJSONString(events.properties.^`$feature_flag_response`), if(isNull(events.properties.`$feature_flag_response`), NULL, if(and(in(ascii(toString(events.properties.`$feature_flag_response`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$feature_flag_response`)), tuple(91, 123))), toJSONString(events.properties.`$feature_flag_response`), toString(events.properties.`$feature_flag_response`)))), ['control', 'test']))
GROUP BY entity_id),
metric_events_by_session AS
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS entity_id,
diff --git a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel.new_events_schema.ambr
index fa7065644db1..957d4cdfdce5 100644
--- a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel.new_events_schema.ambr
@@ -447,7 +447,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 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))
+ 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), 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)
@@ -507,7 +507,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 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))
+ 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), 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)
@@ -567,7 +567,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 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))
+ 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), 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, 2)
@@ -640,7 +640,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 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))
+ 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', 'user signed up')), or(and(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.com%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '20'), 0)), or(ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%.org%'), 0), ifNull(equals(CAST(e.person_properties.age, 'Nullable(String)'), '28'), 0)))), or(equals(step_0, 1), equals(step_1, 1), equals(step_2, 1))))
GROUP BY aggregation_target
HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
GROUP BY breakdown
@@ -982,7 +982,7 @@
if(equals(e.event, 'sign up'), 1, 0) AS step_0,
if(equals(e.event, 'buy'), 1, 0) AS step_1,
[ifNull(toString(if(notEquals(toJSONString(e.properties.^`$browser`), '{}'), toJSONString(e.properties.^`$browser`), if(isNull(nullIf(toString(e.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(e.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$browser`), '[]'), '{}'), toString(e.properties.`$browser`))))), ''),
- ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(nullIf(toString(e.properties.`$version`), '')), NULL, if(and(in(ascii(toString(e.properties.`$version`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$version`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$version`), '[]'), '{}'), toString(e.properties.`$version`))))), '')] AS prop_basic,
+ ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(e.properties.`$version`), NULL, if(and(in(ascii(toString(e.properties.`$version`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$version`)), tuple(91, 123))), toJSONString(e.properties.`$version`), toString(e.properties.`$version`))))), '')] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
diff --git a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.new_events_schema.ambr
index cbf165abe2da..016838ec51ce 100644
--- a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.new_events_schema.ambr
@@ -33,7 +33,7 @@
e.properties.`$window_id` AS `$window_id`,
if(equals(e.event, 'watched movie'), 1, 0) AS step_0,
if(equals(e.event, 'terminate funnel'), 1, 0) AS step_1,
- [if(empty(replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))), ''), '[\\/?#]*$', '')), '/', replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))), ''), '[\\/?#]*$', ''))] AS prop_basic,
+ [if(empty(replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))), ''), '[\\/?#]*$', '')), '/', replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))), ''), '[\\/?#]*$', ''))] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
@@ -103,7 +103,7 @@
e.properties.`$window_id` AS `$window_id`,
if(equals(e.event, 'watched movie'), 1, 0) AS step_0,
if(equals(e.event, 'terminate funnel'), 1, 0) AS step_1,
- [if(empty(replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(nullIf(toString(e.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$pathname`), '[]'), '{}'), toString(e.properties.`$pathname`))))), ''), '[\\/?#]*$', '')), '/', replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(nullIf(toString(e.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$pathname`), '[]'), '{}'), toString(e.properties.`$pathname`))))), ''), '[\\/?#]*$', ''))] AS prop_basic,
+ [if(empty(replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(e.properties.`$pathname`), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), toJSONString(e.properties.`$pathname`), toString(e.properties.`$pathname`))))), ''), '[\\/?#]*$', '')), '/', replaceRegexpOne(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(e.properties.`$pathname`), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), toJSONString(e.properties.`$pathname`), toString(e.properties.`$pathname`))))), ''), '[\\/?#]*$', ''))] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
@@ -173,7 +173,7 @@
e.properties.`$window_id` AS `$window_id`,
if(equals(e.event, 'watched movie'), 1, 0) AS step_0,
if(equals(e.event, 'terminate funnel'), 1, 0) AS step_1,
- [if(empty(replaceRegexpOne(replaceRegexpAll(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(nullIf(toString(e.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$pathname`), '[]'), '{}'), toString(e.properties.`$pathname`))))), ''), '/home.*', '/cleaned-home'), '[\\/?#]*$', '')), '/', replaceRegexpOne(replaceRegexpAll(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(nullIf(toString(e.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$pathname`), '[]'), '{}'), toString(e.properties.`$pathname`))))), ''), '/home.*', '/cleaned-home'), '[\\/?#]*$', ''))] AS prop_basic,
+ [if(empty(replaceRegexpOne(replaceRegexpAll(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(e.properties.`$pathname`), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), toJSONString(e.properties.`$pathname`), toString(e.properties.`$pathname`))))), ''), '/home.*', '/cleaned-home'), '[\\/?#]*$', '')), '/', replaceRegexpOne(replaceRegexpAll(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(e.properties.`$pathname`), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), toJSONString(e.properties.`$pathname`), toString(e.properties.`$pathname`))))), ''), '/home.*', '/cleaned-home'), '[\\/?#]*$', ''))] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
@@ -243,7 +243,7 @@
e.properties.`$window_id` AS `$window_id`,
if(equals(e.event, 'watched movie'), 1, 0) AS step_0,
if(equals(e.event, 'terminate funnel'), 1, 0) AS step_1,
- [replaceRegexpAll(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(nullIf(toString(e.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$pathname`), '[]'), '{}'), toString(e.properties.`$pathname`))))), ''), '/home.*', '/cleaned-home')] AS prop_basic,
+ [replaceRegexpAll(ifNull(toString(if(notEquals(toJSONString(e.properties.^`$pathname`), '{}'), toJSONString(e.properties.^`$pathname`), if(isNull(e.properties.`$pathname`), NULL, if(and(in(ascii(toString(e.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$pathname`)), tuple(91, 123))), toJSONString(e.properties.`$pathname`), toString(e.properties.`$pathname`))))), ''), '/home.*', '/cleaned-home')] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
diff --git a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_strict.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_strict.new_events_schema.ambr
index b61b97a0d46c..067746486f87 100644
--- a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_strict.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_strict.new_events_schema.ambr
@@ -174,7 +174,7 @@
if(equals(e.event, 'sign up'), 1, 0) AS step_0,
if(equals(e.event, 'buy'), 1, 0) AS step_1,
[ifNull(toString(if(notEquals(toJSONString(e.properties.^`$browser`), '{}'), toJSONString(e.properties.^`$browser`), if(isNull(nullIf(toString(e.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(e.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$browser`), '[]'), '{}'), toString(e.properties.`$browser`))))), ''),
- ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(nullIf(toString(e.properties.`$version`), '')), NULL, if(and(in(ascii(toString(e.properties.`$version`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$version`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$version`), '[]'), '{}'), toString(e.properties.`$version`))))), '')] AS prop_basic,
+ ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(e.properties.`$version`), NULL, if(and(in(ascii(toString(e.properties.`$version`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$version`)), tuple(91, 123))), toJSONString(e.properties.`$version`), toString(e.properties.`$version`))))), '')] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
diff --git a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_unordered.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_unordered.new_events_schema.ambr
index c01d907dcb80..8e0de910257a 100644
--- a/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_unordered.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/funnels/test/__snapshots__/test_funnel_unordered.new_events_schema.ambr
@@ -557,7 +557,7 @@
if(equals(e.event, 'sign up'), 1, 0) AS step_0,
if(equals(e.event, 'buy'), 1, 0) AS step_1,
[ifNull(toString(if(notEquals(toJSONString(e.properties.^`$browser`), '{}'), toJSONString(e.properties.^`$browser`), if(isNull(nullIf(toString(e.properties.`$browser`), '')), NULL, if(and(in(ascii(toString(e.properties.`$browser`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$browser`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$browser`), '[]'), '{}'), toString(e.properties.`$browser`))))), ''),
- ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(nullIf(toString(e.properties.`$version`), '')), NULL, if(and(in(ascii(toString(e.properties.`$version`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$version`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$version`), '[]'), '{}'), toString(e.properties.`$version`))))), '')] AS prop_basic,
+ ifNull(toString(if(notEquals(toJSONString(e.properties.^`$version`), '{}'), toJSONString(e.properties.^`$version`), if(isNull(e.properties.`$version`), NULL, if(and(in(ascii(toString(e.properties.`$version`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$version`)), tuple(91, 123))), toJSONString(e.properties.`$version`), toString(e.properties.`$version`))))), '')] AS prop_basic,
prop_basic AS prop
FROM events_json AS e
LEFT OUTER JOIN
diff --git a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.new_events_schema.ambr
index 720899a4ec5c..d2999b583350 100644
--- a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.new_events_schema.ambr
@@ -47,7 +47,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -137,7 +137,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -227,7 +227,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
['/xxx/invalid/*'] AS groupings,
multiMatchAnyIndex(path_item_ungrouped, ['/xxx/invalid/.*']) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -316,7 +316,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
['/bar/*/foo'] AS groupings,
multiMatchAnyIndex(path_item_ungrouped, ['/bar/.*/foo']) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -405,7 +405,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), events.event), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -583,7 +583,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -672,7 +672,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -850,7 +850,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -947,7 +947,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -1044,7 +1044,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -2248,7 +2248,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -2439,26 +2439,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -2643,26 +2643,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -2870,26 +2870,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -3075,26 +3075,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -3303,26 +3303,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -3508,26 +3508,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -3736,26 +3736,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -3940,26 +3940,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -4230,26 +4230,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -4499,26 +4499,26 @@
if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id) AS person_id,
ifNull(if(equals(events.event,
- '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$',
- '\\1'), events.event), '') AS path_item_ungrouped,
- events.uuid AS uuid,
- toTimeZone(events.timestamp,
- 'UTC') AS timestamp,
- ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
- ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
- NULL AS groupings,
- multiMatchAnyIndex(path_item_ungrouped,
- NULL) AS group_index, (if(ifNull(greater(group_index,
- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
+ '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL,
+ if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91,
+ 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$',
+ '\\1'), events.event), '') AS path_item_ungrouped,
+ events.uuid AS uuid,
+ toTimeZone(events.timestamp,
+ 'UTC') AS timestamp,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
+ ifNull(if(notEquals(toJSONString(events.properties.^`$window_id`), '{}'), toJSONString(events.properties.^`$window_id`), if(isNull(nullIf(toString(events.properties.`$window_id`), '')), NULL,
+ if(and(in(ascii(toString(events.properties.`$window_id`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$window_id`)), tuple(91,
+ 123))), nullIf(nullIf(toJSONString(events.properties.`$window_id`), '[]'), '{}'), toString(events.properties.`$window_id`)))), '') AS window_id,
+ NULL AS groupings,
+ multiMatchAnyIndex(path_item_ungrouped,
+ NULL) AS group_index, (if(ifNull(greater(group_index,
+ 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
FROM events_json AS events
LEFT OUTER JOIN (
SELECT argMax(person_distinct_id_overrides.person_id,
@@ -4626,7 +4626,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -4753,7 +4753,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -4851,7 +4851,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -4979,7 +4979,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -5077,7 +5077,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -5167,7 +5167,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -5257,7 +5257,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -5376,7 +5376,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -5499,7 +5499,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -5592,7 +5592,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -5711,7 +5711,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -5804,7 +5804,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -5923,7 +5923,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -6046,7 +6046,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -6169,7 +6169,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
events.uuid AS uuid,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
ifNull(if(notEquals(toJSONString(events.properties.^`$session_id`), '{}'), toJSONString(events.properties.^`$session_id`), if(isNull(nullIf(toString(events.properties.`$session_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$session_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$session_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$session_id`), '[]'), '{}'), toString(events.properties.`$session_id`)))), '') AS session_id,
@@ -6262,7 +6262,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$screen'), if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))), if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event)), '') AS path_item_ungrouped,
NULL AS groupings,
multiMatchAnyIndex(path_item_ungrouped, NULL) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -6351,7 +6351,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
['/bar/*/foo'] AS groupings,
multiMatchAnyIndex(path_item_ungrouped, ['/bar/.*/foo']) AS group_index,
(if(ifNull(greater(group_index, 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item
@@ -6440,7 +6440,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
+ ifNull(if(equals(events.event, '$pageview'), replaceRegexpAll(ifNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), ''), '(.)/$', '\\1'), events.event), '') AS path_item_ungrouped,
['(a+)+',
'[aaa|aaaa]+',
'1.*',
diff --git a/products/product_analytics/backend/hogql_queries/paths_v2/test/__snapshots__/test_paths_v2_query_runner.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/paths_v2/test/__snapshots__/test_paths_v2_query_runner.new_events_schema.ambr
index 889ad01fef0f..b5cade076716 100644
--- a/products/product_analytics/backend/hogql_queries/paths_v2/test/__snapshots__/test_paths_v2_query_runner.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/paths_v2/test/__snapshots__/test_paths_v2_query_runner.new_events_schema.ambr
@@ -20,7 +20,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,
- tuple(events.event, ifNull(multiIf(equals(events.event, '$pageview'), toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), NULL), '')) AS path_item
+ tuple(events.event, ifNull(multiIf(equals(events.event, '$pageview'), toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), NULL), '')) AS path_item
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -96,7 +96,7 @@
FROM
(SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp,
if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,
- tuple(events.event, ifNull(multiIf(equals(events.event, '$pageview'), toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), NULL), '')) AS path_item
+ tuple(events.event, ifNull(multiIf(equals(events.event, '$pageview'), toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), NULL), '')) AS path_item
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
diff --git a/products/product_analytics/backend/hogql_queries/retention/test/__snapshots__/test_retention_query_runner.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/retention/test/__snapshots__/test_retention_query_runner.new_events_schema.ambr
index 14d1170c633d..2a3a9f1a24a1 100644
--- a/products/product_analytics/backend/hogql_queries/retention/test/__snapshots__/test_retention_query_runner.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/retention/test/__snapshots__/test_retention_query_runner.new_events_schema.ambr
@@ -723,7 +723,7 @@
and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,
arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])
and isNull(date_range[plus(start_interval_index, 1)])), [0], []), arrayFilter(x -> ifNull(greater(x, 0), 0), arrayMap(_timestamp -> minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 5), _timestamp), 1), return_event_timestamps)))) AS intervals_from_base,
- argMinIf(ifNull(toString(if(notEquals(toJSONString(events.properties.^plan), '{}'), toJSONString(events.properties.^plan), if(isNull(nullIf(toString(events.properties.plan), '')), NULL, if(and(in(ascii(toString(events.properties.plan)), tuple(91, 123)), in(ascii(toJSONString(events.properties.plan)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.plan), '[]'), '{}'), toString(events.properties.plan))))), ''), toTimeZone(events.timestamp, 'UTC'), equals(events.event, 'signup')) AS breakdown_value
+ argMinIf(ifNull(toString(if(notEquals(toJSONString(events.properties.^plan), '{}'), toJSONString(events.properties.^plan), if(isNull(events.properties.plan), NULL, if(and(in(ascii(toString(events.properties.plan)), tuple(91, 123)), in(ascii(toJSONString(events.properties.plan)), tuple(91, 123))), toJSONString(events.properties.plan), toString(events.properties.plan))))), ''), toTimeZone(events.timestamp, 'UTC'), equals(events.event, 'signup')) AS breakdown_value
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -764,9 +764,9 @@
count(DISTINCT actor_activity.actor_id) AS count
FROM
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,
- if(and(greaterOrEquals(if(equals(minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0)))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), NULL), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(if(equals(minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0)))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), NULL), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), [toTimeZone(toStartOfInterval(if(equals(minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0)))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), NULL), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,
+ if(and(greaterOrEquals(if(equals(minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0)))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), NULL), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(if(equals(minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0)))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), NULL), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), [toTimeZone(toStartOfInterval(if(equals(minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0)))), minIf(toTimeZone(events.timestamp, 'UTC'), and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0))), NULL), toIntervalDay(1)), 'UTC')], []) AS start_event_timestamps,
arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 5)) AS date_range,
- arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%/dash%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,
+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(and(equals(events.event, 'act_a'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%/dash%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS return_event_timestamps,
arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date, _start_event_timestamps) -> if(ifNull(equals(_start_event_timestamps[1], interval_date), isNull(_start_event_timestamps[1])
and isNull(interval_date)), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range, arrayResize([start_event_timestamps], length(date_range), start_event_timestamps)))) AS start_interval_index,
arrayJoin(arrayConcat(if(ifNull(equals(start_event_timestamps[1], date_range[plus(start_interval_index, 1)]), isNull(start_event_timestamps[1])
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_boxplot_trends_query_runner.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_boxplot_trends_query_runner.new_events_schema.ambr
index dd1d3afc91b9..8f803773fca5 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_boxplot_trends_query_runner.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_boxplot_trends_query_runner.new_events_schema.ambr
@@ -250,7 +250,7 @@
avg(accurateCastOrNull(e.properties.revenue, 'Float64')) AS mean_val,
count(accurateCastOrNull(e.properties.revenue, 'Float64')) AS count_val
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2023-12-02 23:59:59', 'UTC'))), ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%@posthog.com%'), 1))
+ WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2023-12-02 23:59:59', 'UTC'))), ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%@posthog.com%'), 1))
GROUP BY day_start
ORDER BY day_start ASC
LIMIT 100 SETTINGS readonly=2,
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_formula.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_formula.new_events_schema.ambr
index b3632c3f4185..719772e0e72e 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_formula.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_formula.new_events_schema.ambr
@@ -61,7 +61,7 @@
FROM
(SELECT ifNull(avg(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
@@ -109,7 +109,7 @@
FROM
(SELECT ifNull(sum(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
@@ -153,7 +153,7 @@
breakdown_value AS breakdown_value
FROM
(SELECT ifNull(avg(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY breakdown_value)
@@ -195,7 +195,7 @@
breakdown_value AS breakdown_value
FROM
(SELECT ifNull(sum(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY breakdown_value)
@@ -453,7 +453,7 @@
FROM
(SELECT ifNull(avg(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(concat(ifNull(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), ''), ' : ', ifNull(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), ''))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(concat(ifNull(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), ''), ' : ', ifNull(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), ''))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
@@ -501,7 +501,7 @@
FROM
(SELECT ifNull(sum(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(concat(ifNull(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), ''), ' : ', ifNull(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), ''))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(concat(ifNull(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), ''), ' : ', ifNull(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), ''))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
@@ -549,7 +549,7 @@
FROM
(SELECT ifNull(avg(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
@@ -597,7 +597,7 @@
FROM
(SELECT ifNull(sum(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
@@ -645,7 +645,7 @@
FROM
(SELECT ifNull(sum(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session end'))
GROUP BY day_start,
@@ -693,7 +693,7 @@
FROM
(SELECT ifNull(sum(accurateCastOrNull(e.properties.xyz, 'Float64')), 0) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(nullIf(toString(e.properties.location), '')), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.location), '[]'), '{}'), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^location), '{}'), toJSONString(e.properties.^location), if(isNull(e.properties.location), NULL, if(and(in(ascii(toString(e.properties.location)), tuple(91, 123)), in(ascii(toJSONString(e.properties.location)), tuple(91, 123))), toJSONString(e.properties.location), toString(e.properties.location))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-28 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-04 23:59:59', 'UTC'))), equals(e.event, 'session start'))
GROUP BY day_start,
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_slope_graph_trends_query_runner.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_slope_graph_trends_query_runner.new_events_schema.ambr
index 1c0299e3d15c..b396b66090fd 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_slope_graph_trends_query_runner.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_slope_graph_trends_query_runner.new_events_schema.ambr
@@ -70,7 +70,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^plan), '{}'), toJSONString(e.properties.^plan), if(isNull(nullIf(toString(e.properties.plan), '')), NULL, if(and(in(ascii(toString(e.properties.plan)), tuple(91, 123)), in(ascii(toJSONString(e.properties.plan)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.plan), '[]'), '{}'), toString(e.properties.plan))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^plan), '{}'), toJSONString(e.properties.^plan), if(isNull(e.properties.plan), NULL, if(and(in(ascii(toString(e.properties.plan)), tuple(91, 123)), in(ascii(toJSONString(e.properties.plan)), tuple(91, 123))), toJSONString(e.properties.plan), toString(e.properties.plan))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2024-05-01 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2024-05-10 23:59:59', 'UTC'))), equals(e.event, '$pageview'), or(and(greaterOrEquals(e.timestamp, parseDateTime64BestEffortOrNull('2024-05-01 00:00:00', 6, 'UTC')), less(e.timestamp, parseDateTime64BestEffortOrNull('2024-05-02 00:00:00', 6, 'UTC'))), and(greaterOrEquals(e.timestamp, parseDateTime64BestEffortOrNull('2024-05-10 00:00:00', 6, 'UTC')), lessOrEquals(e.timestamp, parseDateTime64BestEffortOrNull('2024-05-10 23:59:59', 6, 'UTC')))))
GROUP BY day_start,
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends.new_events_schema.ambr
index 957b59c516c5..b1fda9bc68ee 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends.new_events_schema.ambr
@@ -256,7 +256,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-22 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-05 23:59:59', 'UTC'))), equals(e.event, 'sign up'), and(equals(e.properties.`$browser`, 'Firefox'), equals(e.properties.`$os`, 'Windows')), equals(e.properties.`$os`, 'Mac'))
GROUP BY day_start,
@@ -304,7 +304,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-22 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-05 23:59:59', 'UTC'))), equals(e.event, 'sign up'), or(equals(e.properties.`$browser`, 'Firefox'), equals(e.properties.`$os`, 'Windows')), equals(e.properties.`$os`, 'Mac'))
GROUP BY day_start,
@@ -352,7 +352,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-22 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-05 23:59:59', 'UTC'))), equals(e.event, 'sign up'), and(equals(e.properties.`$browser`, 'Firefox'), equals(e.properties.`$os`, 'Windows')), equals(e.properties.`$os`, 'Mac'))
GROUP BY day_start,
@@ -400,7 +400,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-22 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-05 23:59:59', 'UTC'))), equals(e.event, 'sign up'), or(equals(e.properties.`$browser`, 'Firefox'), equals(e.properties.`$os`, 'Windows')), equals(e.properties.`$os`, 'Mac'))
GROUP BY day_start,
@@ -452,7 +452,7 @@
FROM
(SELECT toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS timestamp,
if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(nullIf(toString(e.properties.key), '')), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.key), '[]'), '{}'), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), toJSONString(e.properties.key), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -524,7 +524,7 @@
FROM
(SELECT toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS timestamp,
if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(nullIf(toString(e.properties.key), '')), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.key), '[]'), '{}'), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), toJSONString(e.properties.key), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -590,7 +590,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(nullIf(toString(e.properties.key), '')), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.key), '[]'), '{}'), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), toJSONString(e.properties.key), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
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,
@@ -646,7 +646,7 @@
FROM
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(nullIf(toString(e.properties.key), '')), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.key), '[]'), '{}'), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^key), '{}'), toJSONString(e.properties.^key), if(isNull(e.properties.key), NULL, if(and(in(ascii(toString(e.properties.key)), tuple(91, 123)), in(ascii(toJSONString(e.properties.key)), tuple(91, 123))), toJSONString(e.properties.key), toString(e.properties.key))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -709,7 +709,7 @@
FROM
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -764,7 +764,7 @@
FROM
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_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,
@@ -819,7 +819,7 @@
FROM
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_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,
@@ -874,7 +874,7 @@
FROM
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1167,7 +1167,7 @@
FROM
(SELECT toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS timestamp,
if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_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,
@@ -1238,7 +1238,7 @@
FROM
(SELECT toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS timestamp,
if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -1334,7 +1334,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -2037,9 +2037,9 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-07-01 23:59:59', 'UTC'))), equals(e.event, 'sign up'), and(equals(e.person_properties.`$os`, 'android'), equals(e.person_properties.`$browser`, 'chrome')), and(ifNull(equals(CAST(e.properties.key, 'Nullable(String)'), 'val'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%@posthog.com%'), 0)))
+ WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-07-01 23:59:59', 'UTC'))), equals(e.event, 'sign up'), and(equals(e.person_properties.`$os`, 'android'), equals(e.person_properties.`$browser`, 'chrome')), and(ifNull(equals(CAST(e.properties.key, 'Nullable(String)'), 'val'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%@posthog.com%'), 0)))
GROUP BY day_start,
breakdown_value)
GROUP BY day_start,
@@ -2085,9 +2085,9 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-07-01 23:59:59', 'UTC'))), equals(e.event, 'sign up'), and(or(ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email))))), '%@posthog.com%'), 1), ifNull(equals(CAST(e.properties.key, 'Nullable(String)'), 'val'), 0)), or(equals(e.person_properties.`$os`, 'android'), equals(e.person_properties.`$browser`, 'safari'))))
+ WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-07-01 23:59:59', 'UTC'))), equals(e.event, 'sign up'), and(or(ifNull(notILike(toString(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email))))), '%@posthog.com%'), 1), ifNull(equals(CAST(e.properties.key, 'Nullable(String)'), 'val'), 0)), or(equals(e.person_properties.`$os`, 'android'), equals(e.person_properties.`$browser`, 'safari'))))
GROUP BY day_start,
breakdown_value)
GROUP BY day_start,
@@ -2166,7 +2166,7 @@
FROM
(SELECT count(DISTINCT e.distinct_id) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-24 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2019-12-31 23:59:59', 'UTC'))), equals(e.event, 'sign up'))
GROUP BY day_start,
@@ -2214,7 +2214,7 @@
FROM
(SELECT count(DISTINCT e.distinct_id) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-24 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2019-12-31 23:59:59', 'UTC'))), equals(e.event, 'sign up'))
GROUP BY day_start,
@@ -2354,7 +2354,7 @@
FROM
(SELECT count(DISTINCT e.distinct_id) AS total,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_prop`), '{}'), toJSONString(e.properties.^`$some_prop`), if(isNull(nullIf(toString(e.properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_prop`), '[]'), '{}'), toString(e.properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_prop`), '{}'), toJSONString(e.properties.^`$some_prop`), if(isNull(e.properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.properties.`$some_prop`), toString(e.properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2019-12-24 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2019-12-31 23:59:59', 'UTC'))), equals(e.event, 'sign up'))
GROUP BY day_start,
@@ -2506,7 +2506,7 @@
FROM
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
min(toStartOfDay(toTimeZone(e.timestamp, 'UTC'))) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -2568,8 +2568,8 @@
(SELECT count(DISTINCT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)) AS total,
min(toStartOfDay(toTimeZone(e.timestamp, 'UTC'))) AS day_start,
ifNull(nullIf(leftUTF8(toString(if(empty(trim(TRAILING '/?#'
- FROM if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`)))))), '/', trim(TRAILING '/?#'
- FROM if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(nullIf(toString(e.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$current_url`), '[]'), '{}'), toString(e.properties.`$current_url`))))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ FROM if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`)))))), '/', trim(TRAILING '/?#'
+ FROM if(notEquals(toJSONString(e.properties.^`$current_url`), '{}'), toJSONString(e.properties.^`$current_url`), if(isNull(e.properties.`$current_url`), NULL, if(and(in(ascii(toString(e.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$current_url`)), tuple(91, 123))), toJSONString(e.properties.`$current_url`), toString(e.properties.`$current_url`))))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -2624,7 +2624,7 @@
breakdown_value AS breakdown_value
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT JOIN
(SELECT dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))) AS `$session_duration`,
@@ -2677,7 +2677,7 @@
breakdown_value_1 AS breakdown_value_1
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS e
LEFT JOIN
(SELECT dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))) AS `$session_duration`,
@@ -2730,7 +2730,7 @@
breakdown_value_1 AS breakdown_value_1
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS e
LEFT JOIN
(SELECT dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))) AS `$session_duration`,
@@ -2783,7 +2783,7 @@
breakdown_value AS breakdown_value
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT JOIN
(SELECT dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))) AS `$session_duration`,
@@ -2971,7 +2971,7 @@
breakdown_value AS breakdown_value
FROM
(SELECT count() AS total,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^color), '{}'), toJSONString(e.properties.^color), if(isNull(nullIf(toString(e.properties.color), '')), NULL, if(and(in(ascii(toString(e.properties.color)), tuple(91, 123)), in(ascii(toJSONString(e.properties.color)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.color), '[]'), '{}'), toString(e.properties.color))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^color), '{}'), toJSONString(e.properties.^color), if(isNull(e.properties.color), NULL, if(and(in(ascii(toString(e.properties.color)), tuple(91, 123)), in(ascii(toJSONString(e.properties.color)), tuple(91, 123))), toJSONString(e.properties.color), toString(e.properties.color))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -3227,7 +3227,7 @@
breakdown_value_1 AS breakdown_value_1
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1
FROM events_json AS e
LEFT JOIN
(SELECT dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))) AS `$session_duration`,
@@ -3280,7 +3280,7 @@
breakdown_value AS breakdown_value
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(nullIf(toString(e.person_properties.`$some_prop`), '')), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.`$some_prop`), '[]'), '{}'), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.person_properties.^`$some_prop`), '{}'), toJSONString(e.person_properties.^`$some_prop`), if(isNull(e.person_properties.`$some_prop`), NULL, if(and(in(ascii(toString(e.person_properties.`$some_prop`)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.`$some_prop`)), tuple(91, 123))), toJSONString(e.person_properties.`$some_prop`), toString(e.person_properties.`$some_prop`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
FROM events_json AS e
LEFT JOIN
(SELECT dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))) AS `$session_duration`,
@@ -3522,7 +3522,7 @@
day_start AS day_start
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value,
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start
FROM events_json AS e
LEFT JOIN
@@ -3584,7 +3584,7 @@
day_start AS day_start
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
toStartOfWeek(toTimeZone(e.timestamp, 'UTC'), 0) AS day_start
FROM events_json AS e
LEFT JOIN
@@ -3646,7 +3646,7 @@
day_start AS day_start
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1,
toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start
FROM events_json AS e
LEFT JOIN
@@ -3708,7 +3708,7 @@
day_start AS day_start
FROM
(SELECT any(e__session.`$session_duration`) AS session_duration,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(nullIf(toString(e.properties.`$some_property`), '')), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.`$some_property`), '[]'), '{}'), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value,
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^`$some_property`), '{}'), toJSONString(e.properties.^`$some_property`), if(isNull(e.properties.`$some_property`), NULL, if(and(in(ascii(toString(e.properties.`$some_property`)), tuple(91, 123)), in(ascii(toJSONString(e.properties.`$some_property`)), tuple(91, 123))), toJSONString(e.properties.`$some_property`), toString(e.properties.`$some_property`))))), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value,
toStartOfWeek(toTimeZone(e.timestamp, 'UTC'), 0) AS day_start
FROM events_json AS e
LEFT JOIN
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_data_warehouse_query.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_data_warehouse_query.new_events_schema.ambr
index 93f2bf759d65..bc0672565e0f 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_data_warehouse_query.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_data_warehouse_query.new_events_schema.ambr
@@ -69,7 +69,7 @@
LEFT JOIN
(SELECT posthog_test_test_table_1.id AS id,
posthog_test_test_table_1.prop_1 AS e__posthog_test_test_table_1___prop_1
- FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/posthog_test_test_table_1/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS posthog_test_test_table_1) AS e__posthog_test_test_table_1 ON equals(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))), e__posthog_test_test_table_1.e__posthog_test_test_table_1___prop_1)
+ FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-posthog.hogql.datawarehouse.trendquery/posthog_test_test_table_1/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` String, `prop_1` String, `prop_2` String, `created` DateTime64(3, \'UTC\')') AS posthog_test_test_table_1) AS e__posthog_test_test_table_1 ON equals(if(notEquals(toJSONString(e.person_properties.^email), '{}'), toJSONString(e.person_properties.^email), if(isNull(e.person_properties.email), NULL, if(and(in(ascii(toString(e.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(e.person_properties.email)), tuple(91, 123))), toJSONString(e.person_properties.email), toString(e.person_properties.email)))), e__posthog_test_test_table_1.e__posthog_test_test_table_1___prop_1)
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime('2022-12-01 00:00:00', 'UTC')), toIntervalDay(1)), 6, 'UTC')), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2023-01-07 23:59:59', 'UTC'))), equals(e.event, '$pageview'), equals(e__posthog_test_test_table_1.id, 'false'))
GROUP BY day_start)
GROUP BY day_start
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_query_builder.new_events_schema.ambr b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_query_builder.new_events_schema.ambr
index a9c43aa74aee..98de4a8d7a22 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_query_builder.new_events_schema.ambr
+++ b/products/product_analytics/backend/hogql_queries/trends/test/__snapshots__/test_trends_query_builder.new_events_schema.ambr
@@ -31,7 +31,7 @@
FROM
(SELECT count() AS total,
toStartOfDay(toTimeZone(e.timestamp, %(hogql_val_0)s)) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^bucket), '{}'), toJSONString(e.properties.^bucket), if(isNull(nullIf(toString(e.properties.bucket), '')), NULL, if(and(in(ascii(toString(e.properties.bucket)), tuple(91, 123)), in(ascii(toJSONString(e.properties.bucket)), tuple(91, 123))), nullIf(nullIf(toJSONString(e.properties.bucket), '[]'), '{}'), toString(e.properties.bucket))))), 400), %(hogql_val_1)s), %(hogql_val_2)s) AS breakdown_value
+ ifNull(nullIf(leftUTF8(toString(if(notEquals(toJSONString(e.properties.^bucket), '{}'), toJSONString(e.properties.^bucket), if(isNull(e.properties.bucket), NULL, if(and(in(ascii(toString(e.properties.bucket)), tuple(91, 123)), in(ascii(toJSONString(e.properties.bucket)), tuple(91, 123))), toJSONString(e.properties.bucket), toString(e.properties.bucket))))), 400), %(hogql_val_1)s), %(hogql_val_2)s) AS breakdown_value
FROM events_json AS e
WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toDateTime64(toStartOfInterval(assumeNotNull(toDateTime(%(hogql_val_3)s, %(hogql_val_4)s)), toIntervalDay(1)), 6, %(hogql_val_5)s)), lessOrEquals(e.timestamp, assumeNotNull(toDateTime(%(hogql_val_6)s, %(hogql_val_7)s))), equals(e.event, %(hogql_val_8)s))
GROUP BY day_start,
diff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_calendar_heatmap_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/test/test_calendar_heatmap_query_runner.py
index 56ed31ab867d..ececf95f7df1 100644
--- a/products/product_analytics/backend/hogql_queries/trends/test/test_calendar_heatmap_query_runner.py
+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_calendar_heatmap_query_runner.py
@@ -3,8 +3,6 @@ from typing import Optional
import time_machine
from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event, _create_person
-from django.conf import settings
-
from parameterized import parameterized
from posthog.schema import (
@@ -961,13 +959,11 @@ class TestCalendarHeatmapQueryRunner(ClickhouseTestMixin, APIBaseTest):
properties=[{"key": "empty_string", "value": ""}],
)
results_dict = {(r.row, r.column): r.value for r in response.results.data}
- # On the native-JSON table an empty value is absent, like a materialized column, so the filter matches nothing.
- expected_matches = 0 if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else 1
- assert (results_dict.get((6, 10)) or 0) == expected_matches, (
- f"Expected {expected_matches} empty string event(s) at 10:00, got {results_dict.get((6, 10))}"
+ assert results_dict.get((6, 10)) == 1, (
+ f"Expected 1 empty string event at 10:00, got {results_dict.get((6, 10))}"
)
- assert response.results.allAggregations == expected_matches, (
- f"Expected {expected_matches} total empty string event(s), got {response.results.allAggregations}"
+ assert response.results.allAggregations == 1, (
+ f"Expected 1 total empty string event, got {response.results.allAggregations}"
)
# Test with non-existent property filter
diff --git a/products/revenue_analytics/backend/views/test/__snapshots__/test_mrr_views.new_events_schema.ambr b/products/revenue_analytics/backend/views/test/__snapshots__/test_mrr_views.new_events_schema.ambr
index 1f9a2e693922..1aa08a9e26aa 100644
--- a/products/revenue_analytics/backend/views/test/__snapshots__/test_mrr_views.new_events_schema.ambr
+++ b/products/revenue_analytics/backend/views/test/__snapshots__/test_mrr_views.new_events_schema.ambr
@@ -19,8 +19,8 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(nullIf(toString(events.properties.subscription), '')), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription), '[]'), '{}'), toString(events.properties.subscription))))) AS is_recurring,
- if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(nullIf(toString(events.properties.product), '')), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.product), '[]'), '{}'), toString(events.properties.product)))) AS product_id,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(events.properties.subscription), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), toJSONString(events.properties.subscription), toString(events.properties.subscription))))) AS is_recurring,
+ if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(events.properties.product), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), toJSONString(events.properties.product), toString(events.properties.product)))) AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
events.properties.`$group_1` AS group_1_key,
@@ -28,18 +28,18 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(nullIf(toString(events.properties.subscription), '')), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription), '[]'), '{}'), toString(events.properties.subscription)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(events.properties.subscription), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), toJSONString(events.properties.subscription), toString(events.properties.subscription)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
- if(notEquals(toJSONString(events.properties.^coupon), '{}'), toJSONString(events.properties.^coupon), if(isNull(nullIf(toString(events.properties.coupon), '')), NULL, if(and(in(ascii(toString(events.properties.coupon)), tuple(91, 123)), in(ascii(toJSONString(events.properties.coupon)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.coupon), '[]'), '{}'), toString(events.properties.coupon)))) AS coupon,
+ if(notEquals(toJSONString(events.properties.^coupon), '{}'), toJSONString(events.properties.^coupon), if(isNull(events.properties.coupon), NULL, if(and(in(ascii(toString(events.properties.coupon)), tuple(91, 123)), in(ascii(toJSONString(events.properties.coupon)), tuple(91, 123))), toJSONString(events.properties.coupon), toString(events.properties.coupon)))) AS coupon,
coupon AS coupon_id,
- upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))) AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))) AS original_currency,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
1 AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount,
'GBP' AS currency,
- if(isNull(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency)))))), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ if(isNull(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency)))))), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -72,8 +72,8 @@
NULL AS metadata
FROM
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(nullIf(toString(events.properties.subscription), '')), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription), '[]'), '{}'), toString(events.properties.subscription)))) AS subscription_id,
- min(if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(nullIf(toString(events.properties.product), '')), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.product), '[]'), '{}'), toString(events.properties.product))))) AS product_id,
+ if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(events.properties.subscription), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), toJSONString(events.properties.subscription), toString(events.properties.subscription)))) AS subscription_id,
+ min(if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(events.properties.product), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), toJSONString(events.properties.product), toString(events.properties.product))))) AS product_id,
min(toTimeZone(events.timestamp, 'UTC')) AS min_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS max_timestamp,
addDays(max_timestamp, 45.0) AS max_timestamp_plus_dropoff_days
@@ -137,8 +137,8 @@
'revenue_analytics.events.purchase' AS source_label,
toTimeZone(events.timestamp, 'UTC') AS timestamp,
timestamp AS created_at,
- isNotNull(if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(nullIf(toString(events.properties.subscription), '')), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription), '[]'), '{}'), toString(events.properties.subscription))))) AS is_recurring,
- if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(nullIf(toString(events.properties.product), '')), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.product), '[]'), '{}'), toString(events.properties.product)))) AS product_id,
+ isNotNull(if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(events.properties.subscription), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), toJSONString(events.properties.subscription), toString(events.properties.subscription))))) AS is_recurring,
+ if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(events.properties.product), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), toJSONString(events.properties.product), toString(events.properties.product)))) AS product_id,
toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id,
events.properties.`$group_0` AS group_0_key,
events.properties.`$group_1` AS group_1_key,
@@ -146,18 +146,18 @@
events.properties.`$group_3` AS group_3_key,
events.properties.`$group_4` AS group_4_key,
NULL AS invoice_id,
- if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(nullIf(toString(events.properties.subscription), '')), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription), '[]'), '{}'), toString(events.properties.subscription)))) AS subscription_id,
+ if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(events.properties.subscription), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), toJSONString(events.properties.subscription), toString(events.properties.subscription)))) AS subscription_id,
toString(events.properties.`$session_id`) AS session_id,
events.event AS event_name,
- if(notEquals(toJSONString(events.properties.^coupon), '{}'), toJSONString(events.properties.^coupon), if(isNull(nullIf(toString(events.properties.coupon), '')), NULL, if(and(in(ascii(toString(events.properties.coupon)), tuple(91, 123)), in(ascii(toJSONString(events.properties.coupon)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.coupon), '[]'), '{}'), toString(events.properties.coupon)))) AS coupon,
+ if(notEquals(toJSONString(events.properties.^coupon), '{}'), toJSONString(events.properties.^coupon), if(isNull(events.properties.coupon), NULL, if(and(in(ascii(toString(events.properties.coupon)), tuple(91, 123)), in(ascii(toJSONString(events.properties.coupon)), tuple(91, 123))), toJSONString(events.properties.coupon), toString(events.properties.coupon)))) AS coupon,
coupon AS coupon_id,
- upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))) AS original_currency,
- accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(nullIf(toString(events.properties.revenue), '')), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.revenue), '[]'), '{}'), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
+ upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))) AS original_currency,
+ accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(and(in(ascii(toString(events.properties.revenue)), tuple(91, 123)), in(ascii(toJSONString(events.properties.revenue)), tuple(91, 123))), toJSONString(events.properties.revenue), toString(events.properties.revenue)))), 'Decimal64(10)') AS original_amount,
1 AS enable_currency_aware_divider,
if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider,
divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount,
'GBP' AS currency,
- if(isNull(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency)))))), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(nullIf(toString(events.properties.currency), '')), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.currency), '[]'), '{}'), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
+ if(isNull(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency)))))), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals(upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), 'GBP'), toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), ifNull(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', upper(if(notEquals(toJSONString(events.properties.^currency), '{}'), toJSONString(events.properties.^currency), if(isNull(events.properties.currency), NULL, if(and(in(ascii(toString(events.properties.currency)), tuple(91, 123)), in(ascii(toJSONString(events.properties.currency)), tuple(91, 123))), toJSONString(events.properties.currency), toString(events.properties.currency))))), toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'GBP', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount
FROM events_json AS events
LEFT OUTER JOIN
(SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
@@ -190,8 +190,8 @@
NULL AS metadata
FROM
(SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id,
- if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(nullIf(toString(events.properties.subscription), '')), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.subscription), '[]'), '{}'), toString(events.properties.subscription)))) AS subscription_id,
- min(if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(nullIf(toString(events.properties.product), '')), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.product), '[]'), '{}'), toString(events.properties.product))))) AS product_id,
+ if(notEquals(toJSONString(events.properties.^subscription), '{}'), toJSONString(events.properties.^subscription), if(isNull(events.properties.subscription), NULL, if(and(in(ascii(toString(events.properties.subscription)), tuple(91, 123)), in(ascii(toJSONString(events.properties.subscription)), tuple(91, 123))), toJSONString(events.properties.subscription), toString(events.properties.subscription)))) AS subscription_id,
+ min(if(notEquals(toJSONString(events.properties.^product), '{}'), toJSONString(events.properties.^product), if(isNull(events.properties.product), NULL, if(and(in(ascii(toString(events.properties.product)), tuple(91, 123)), in(ascii(toJSONString(events.properties.product)), tuple(91, 123))), toJSONString(events.properties.product), toString(events.properties.product))))) AS product_id,
min(toTimeZone(events.timestamp, 'UTC')) AS min_timestamp,
max(toTimeZone(events.timestamp, 'UTC')) AS max_timestamp,
addDays(max_timestamp, 45.0) AS max_timestamp_plus_dropoff_days
diff --git a/products/surveys/backend/api/test/__snapshots__/test_survey.new_events_schema.ambr b/products/surveys/backend/api/test/__snapshots__/test_survey.new_events_schema.ambr
index fc9dfa05a884..3f273f58cdc9 100644
--- a/products/surveys/backend/api/test/__snapshots__/test_survey.new_events_schema.ambr
+++ b/products/surveys/backend/api/test/__snapshots__/test_survey.new_events_schema.ambr
@@ -5,12 +5,12 @@
SELECT survey_id AS survey_id,
count() AS `count()`
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(events.properties.`$survey_id`)))) AS survey_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(events.properties.`$survey_id`)))) AS survey_id,
argMax(events.uuid, tuple(toTimeZone(events.timestamp, 'UTC'), events.uuid)) AS response_uuid
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'survey sent'), and(in(events.event, tuple('survey dismissed', 'survey abandoned')), equals(coalesce(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^`$survey_partially_completed`), '{}'), toJSONString(events.properties.^`$survey_partially_completed`), if(isNull(nullIf(toString(events.properties.`$survey_partially_completed`), '')), NULL, nullIf(nullIf(toJSONString(events.properties.`$survey_partially_completed`), '[]'), '{}'))), '')), ''), 'true'))), greaterOrEquals(events.timestamp, toDateTime64('2024-01-21 14:40:09.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'survey sent'), and(in(events.event, tuple('survey dismissed', 'survey abandoned')), equals(coalesce(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^`$survey_partially_completed`), '{}'), toJSONString(events.properties.^`$survey_partially_completed`), if(isNull(events.properties.`$survey_partially_completed`), NULL, toJSONString(events.properties.`$survey_partially_completed`))), '')), ''), 'true'))), greaterOrEquals(events.timestamp, toDateTime64('2024-01-21 14:40:09.000000', 6, 'UTC')))
GROUP BY survey_id,
- if(ifNull(equals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`)))), ''), ''), 0), toString(events.uuid), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`))))))
+ if(ifNull(equals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`)))), ''), ''), 0), toString(events.uuid), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))))
GROUP BY survey_id
LIMIT 50000 SETTINGS readonly=2,
max_execution_time=60,
@@ -34,12 +34,12 @@
SELECT survey_id AS survey_id,
count() AS `count()`
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(events.properties.`$survey_id`)))) AS survey_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(events.properties.`$survey_id`)))) AS survey_id,
argMax(events.uuid, tuple(toTimeZone(events.timestamp, 'UTC'), events.uuid)) AS response_uuid
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'survey sent'), and(in(events.event, tuple('survey dismissed', 'survey abandoned')), equals(coalesce(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^`$survey_partially_completed`), '{}'), toJSONString(events.properties.^`$survey_partially_completed`), if(isNull(nullIf(toString(events.properties.`$survey_partially_completed`), '')), NULL, nullIf(nullIf(toJSONString(events.properties.`$survey_partially_completed`), '[]'), '{}'))), '')), ''), 'true'))), greaterOrEquals(events.timestamp, toDateTime64('2024-04-25 14:40:09.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'survey sent'), and(in(events.event, tuple('survey dismissed', 'survey abandoned')), equals(coalesce(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^`$survey_partially_completed`), '{}'), toJSONString(events.properties.^`$survey_partially_completed`), if(isNull(events.properties.`$survey_partially_completed`), NULL, toJSONString(events.properties.`$survey_partially_completed`))), '')), ''), 'true'))), greaterOrEquals(events.timestamp, toDateTime64('2024-04-25 14:40:09.000000', 6, 'UTC')))
GROUP BY survey_id,
- if(ifNull(equals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`)))), ''), ''), 0), toString(events.uuid), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`))))))
+ if(ifNull(equals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`)))), ''), ''), 0), toString(events.uuid), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))))
GROUP BY survey_id
LIMIT 50000 SETTINGS readonly=2,
max_execution_time=60,
@@ -63,12 +63,12 @@
SELECT survey_id AS survey_id,
count() AS `count()`
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(nullIf(toString(events.properties.`$survey_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_id`), '[]'), '{}'), toString(events.properties.`$survey_id`)))) AS survey_id,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$survey_id`), '{}'), toJSONString(events.properties.^`$survey_id`), if(isNull(events.properties.`$survey_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_id`), toString(events.properties.`$survey_id`)))) AS survey_id,
argMax(events.uuid, tuple(toTimeZone(events.timestamp, 'UTC'), events.uuid)) AS response_uuid
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'survey sent'), and(in(events.event, tuple('survey dismissed', 'survey abandoned')), equals(coalesce(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^`$survey_partially_completed`), '{}'), toJSONString(events.properties.^`$survey_partially_completed`), if(isNull(nullIf(toString(events.properties.`$survey_partially_completed`), '')), NULL, nullIf(nullIf(toJSONString(events.properties.`$survey_partially_completed`), '[]'), '{}'))), '')), ''), 'true'))), greaterOrEquals(events.timestamp, toDateTime64('2024-06-10 11:00:00.000000', 6, 'UTC')))
+ WHERE and(equals(events.team_id, 99999), or(equals(events.event, 'survey sent'), and(in(events.event, tuple('survey dismissed', 'survey abandoned')), equals(coalesce(JSONExtractString(ifNull(if(notEquals(toJSONString(events.properties.^`$survey_partially_completed`), '{}'), toJSONString(events.properties.^`$survey_partially_completed`), if(isNull(events.properties.`$survey_partially_completed`), NULL, toJSONString(events.properties.`$survey_partially_completed`))), '')), ''), 'true'))), greaterOrEquals(events.timestamp, toDateTime64('2024-06-10 11:00:00.000000', 6, 'UTC')))
GROUP BY survey_id,
- if(ifNull(equals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`)))), ''), ''), 0), toString(events.uuid), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(nullIf(toString(events.properties.`$survey_submission_id`), '')), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$survey_submission_id`), '[]'), '{}'), toString(events.properties.`$survey_submission_id`))))))
+ if(ifNull(equals(coalesce(if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`)))), ''), ''), 0), toString(events.uuid), if(notEquals(toJSONString(events.properties.^`$survey_submission_id`), '{}'), toJSONString(events.properties.^`$survey_submission_id`), if(isNull(events.properties.`$survey_submission_id`), NULL, if(and(in(ascii(toString(events.properties.`$survey_submission_id`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$survey_submission_id`)), tuple(91, 123))), toJSONString(events.properties.`$survey_submission_id`), toString(events.properties.`$survey_submission_id`))))))
GROUP BY survey_id
LIMIT 50000 SETTINGS readonly=2,
max_execution_time=60,
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_external_clicks_table.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_external_clicks_table.new_events_schema.ambr
index c1014cccdd5a..27e3dcfbac3f 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_external_clicks_table.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_external_clicks_table.new_events_schema.ambr
@@ -7,7 +7,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -23,8 +23,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -77,7 +77,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -93,8 +93,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -125,7 +125,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -141,8 +141,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -173,7 +173,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -189,8 +189,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -221,7 +221,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -237,8 +237,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -269,7 +269,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -285,8 +285,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-11 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-11 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -317,7 +317,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -333,8 +333,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -365,7 +365,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -381,8 +381,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -413,7 +413,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))), '/items/\\d+', '/items/:id') AS url,
+ replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))), '/items/\\d+', '/items/:id') AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -429,8 +429,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -461,7 +461,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -477,8 +477,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -509,7 +509,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -525,8 +525,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -557,7 +557,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`)))) AS url,
+ if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`)))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -573,8 +573,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
@@ -605,7 +605,7 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
count() AS filtered_click_count,
- cutQueryStringAndFragment(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))) AS url,
+ cutQueryStringAndFragment(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))) AS url,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN
@@ -621,8 +621,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(nullIf(toString(events.properties.`$external_click_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$external_click_url`), '[]'), '{}'), toString(events.properties.`$external_click_url`))))))
- or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$autocapture'), ifNull(equals(CAST(events.properties.`$event_type`, 'Nullable(String)'), 'click'), 0), isNotNull(url), ifNull(notEquals(url, ''), 1), ifNull(notEquals(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))), cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`)))))), isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$external_click_url`), '{}'), toJSONString(events.properties.^`$external_click_url`), if(isNull(events.properties.`$external_click_url`), NULL, if(and(in(ascii(toString(events.properties.`$external_click_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$external_click_url`)), tuple(91, 123))), toJSONString(events.properties.`$external_click_url`), toString(events.properties.`$external_click_url`))))))
+ or isNotNull(cutToFirstSignificantSubdomain(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
GROUP BY events.properties.`$session_id`,
url)
GROUP BY `context.columns.url`
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_notable_changes.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_notable_changes.new_events_schema.ambr
index 99ff63e00687..0ff7f488a961 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_notable_changes.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_notable_changes.new_events_schema.ambr
@@ -18,12 +18,12 @@
FROM (
SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id)) AS person_id,
- nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), ''), 'null') AS dimension_value,
- events__session.session_id AS session_id,
- min(events__session.`$start_timestamp`) AS start_timestamp
+ nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL,
+ if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
+ 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), ''), 'null') AS dimension_value,
+ events__session.session_id AS session_id,
+ min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN (
SELECT toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7,
@@ -68,10 +68,10 @@
'UTC'), assumeNotNull(toDateTime('2025-01-22 23:59:59',
'UTC'))))), 1))
GROUP BY events__session.session_id,
- nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), ''), 'null'))
+ nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL,
+ if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
+ 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), ''), 'null'))
GROUP BY dimension_value
HAVING and(isNotNull(dimension_value), ifNull(notEquals(dimension_value,
''), 1))
@@ -659,12 +659,12 @@
FROM (
SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id)) AS person_id,
- nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), ''), 'null') AS dimension_value,
- events__session.session_id AS session_id,
- min(events__session.`$start_timestamp`) AS start_timestamp
+ nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL,
+ if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
+ 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), ''), 'null') AS dimension_value,
+ events__session.session_id AS session_id,
+ min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN (
SELECT toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7,
@@ -709,10 +709,10 @@
'UTC'), assumeNotNull(toDateTime('2025-01-22 23:59:59',
'UTC'))))), 1))
GROUP BY events__session.session_id,
- nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), ''), 'null'))
+ nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL,
+ if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
+ 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), ''), 'null'))
GROUP BY dimension_value
HAVING and(isNotNull(dimension_value), ifNull(notEquals(dimension_value,
''), 1))
@@ -1300,12 +1300,12 @@
FROM (
SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id,
events.person_id)) AS person_id,
- nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), ''), 'null') AS dimension_value,
- events__session.session_id AS session_id,
- min(events__session.`$start_timestamp`) AS start_timestamp
+ nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL,
+ if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
+ 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), ''), 'null') AS dimension_value,
+ events__session.session_id AS session_id,
+ min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
LEFT JOIN (
SELECT toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7,
@@ -1350,10 +1350,10 @@
'UTC'), assumeNotNull(toDateTime('2025-01-22 23:59:59',
'UTC'))))), 1))
GROUP BY events__session.session_id,
- nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL,
- if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
- 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
- 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), ''), 'null'))
+ nullIf(nullIf(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL,
+ if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91,
+ 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91,
+ 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), ''), 'null'))
GROUP BY dimension_value
HAVING and(isNotNull(dimension_value), ifNull(notEquals(dimension_value,
''), 1))
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_traffic_type_snapshot.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_traffic_type_snapshot.new_events_schema.ambr
index 0b08a4468c94..c6a1ac6afd20 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_traffic_type_snapshot.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_traffic_type_snapshot.new_events_schema.ambr
@@ -4,11 +4,11 @@
-- ClickHouse
SELECT
events.event AS event,
- if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))) AS user_agent
+ if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))) AS user_agent
FROM
events_json AS events
WHERE
- and(equals(events.team_id, 99999), equals(events.event, %(hogql_val_0)s), not(accurateCastOrNull(ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_1)s), [%(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s, %(hogql_val_345)s]), 0), 1), %(hogql_val_346)s)))
+ and(equals(events.team_id, 99999), equals(events.event, %(hogql_val_0)s), not(accurateCastOrNull(ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_1)s), [%(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s, %(hogql_val_345)s]), 0), 1), %(hogql_val_346)s)))
ORDER BY
user_agent ASC
LIMIT 100
@@ -31,7 +31,7 @@
'''
-- ClickHouse
SELECT
- if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS bot_name,
+ if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS bot_name,
count() AS count
FROM
events_json AS events
@@ -63,7 +63,7 @@
'''
-- ClickHouse
SELECT
- if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS bot_type,
+ if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS bot_type,
count() AS count
FROM
events_json AS events
@@ -95,7 +95,7 @@
'''
-- ClickHouse
SELECT
- if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS category,
+ if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS category,
count() AS count
FROM
events_json AS events
@@ -127,7 +127,7 @@
'''
-- ClickHouse
SELECT
- if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS traffic_type,
+ if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 0), %(hogql_val_345)s, [%(hogql_val_346)s, %(hogql_val_347)s, %(hogql_val_348)s, %(hogql_val_349)s, %(hogql_val_350)s, %(hogql_val_351)s, %(hogql_val_352)s, %(hogql_val_353)s, %(hogql_val_354)s, %(hogql_val_355)s, %(hogql_val_356)s, %(hogql_val_357)s, %(hogql_val_358)s, %(hogql_val_359)s, %(hogql_val_360)s, %(hogql_val_361)s, %(hogql_val_362)s, %(hogql_val_363)s, %(hogql_val_364)s, %(hogql_val_365)s, %(hogql_val_366)s, %(hogql_val_367)s, %(hogql_val_368)s, %(hogql_val_369)s, %(hogql_val_370)s, %(hogql_val_371)s, %(hogql_val_372)s, %(hogql_val_373)s, %(hogql_val_374)s, %(hogql_val_375)s, %(hogql_val_376)s, %(hogql_val_377)s, %(hogql_val_378)s, %(hogql_val_379)s, %(hogql_val_380)s, %(hogql_val_381)s, %(hogql_val_382)s, %(hogql_val_383)s, %(hogql_val_384)s, %(hogql_val_385)s, %(hogql_val_386)s, %(hogql_val_387)s, %(hogql_val_388)s, %(hogql_val_389)s, %(hogql_val_390)s, %(hogql_val_391)s, %(hogql_val_392)s, %(hogql_val_393)s, %(hogql_val_394)s, %(hogql_val_395)s, %(hogql_val_396)s, %(hogql_val_397)s, %(hogql_val_398)s, %(hogql_val_399)s, %(hogql_val_400)s, %(hogql_val_401)s, %(hogql_val_402)s, %(hogql_val_403)s, %(hogql_val_404)s, %(hogql_val_405)s, %(hogql_val_406)s, %(hogql_val_407)s, %(hogql_val_408)s, %(hogql_val_409)s, %(hogql_val_410)s, %(hogql_val_411)s, %(hogql_val_412)s, %(hogql_val_413)s, %(hogql_val_414)s, %(hogql_val_415)s, %(hogql_val_416)s, %(hogql_val_417)s, %(hogql_val_418)s, %(hogql_val_419)s, %(hogql_val_420)s, %(hogql_val_421)s, %(hogql_val_422)s, %(hogql_val_423)s, %(hogql_val_424)s, %(hogql_val_425)s, %(hogql_val_426)s, %(hogql_val_427)s, %(hogql_val_428)s, %(hogql_val_429)s, %(hogql_val_430)s, %(hogql_val_431)s, %(hogql_val_432)s, %(hogql_val_433)s, %(hogql_val_434)s, %(hogql_val_435)s, %(hogql_val_436)s, %(hogql_val_437)s, %(hogql_val_438)s, %(hogql_val_439)s, %(hogql_val_440)s, %(hogql_val_441)s, %(hogql_val_442)s, %(hogql_val_443)s, %(hogql_val_444)s, %(hogql_val_445)s, %(hogql_val_446)s, %(hogql_val_447)s, %(hogql_val_448)s, %(hogql_val_449)s, %(hogql_val_450)s, %(hogql_val_451)s, %(hogql_val_452)s, %(hogql_val_453)s, %(hogql_val_454)s, %(hogql_val_455)s, %(hogql_val_456)s, %(hogql_val_457)s, %(hogql_val_458)s, %(hogql_val_459)s, %(hogql_val_460)s, %(hogql_val_461)s, %(hogql_val_462)s, %(hogql_val_463)s, %(hogql_val_464)s, %(hogql_val_465)s, %(hogql_val_466)s, %(hogql_val_467)s, %(hogql_val_468)s, %(hogql_val_469)s, %(hogql_val_470)s, %(hogql_val_471)s, %(hogql_val_472)s, %(hogql_val_473)s, %(hogql_val_474)s, %(hogql_val_475)s, %(hogql_val_476)s, %(hogql_val_477)s, %(hogql_val_478)s, %(hogql_val_479)s, %(hogql_val_480)s, %(hogql_val_481)s, %(hogql_val_482)s, %(hogql_val_483)s, %(hogql_val_484)s, %(hogql_val_485)s, %(hogql_val_486)s, %(hogql_val_487)s, %(hogql_val_488)s, %(hogql_val_489)s, %(hogql_val_490)s, %(hogql_val_491)s, %(hogql_val_492)s, %(hogql_val_493)s, %(hogql_val_494)s, %(hogql_val_495)s, %(hogql_val_496)s, %(hogql_val_497)s, %(hogql_val_498)s, %(hogql_val_499)s, %(hogql_val_500)s, %(hogql_val_501)s, %(hogql_val_502)s, %(hogql_val_503)s, %(hogql_val_504)s, %(hogql_val_505)s, %(hogql_val_506)s, %(hogql_val_507)s, %(hogql_val_508)s, %(hogql_val_509)s, %(hogql_val_510)s, %(hogql_val_511)s, %(hogql_val_512)s, %(hogql_val_513)s, %(hogql_val_514)s, %(hogql_val_515)s, %(hogql_val_516)s, %(hogql_val_517)s, %(hogql_val_518)s, %(hogql_val_519)s, %(hogql_val_520)s, %(hogql_val_521)s, %(hogql_val_522)s, %(hogql_val_523)s, %(hogql_val_524)s, %(hogql_val_525)s, %(hogql_val_526)s, %(hogql_val_527)s, %(hogql_val_528)s, %(hogql_val_529)s, %(hogql_val_530)s, %(hogql_val_531)s, %(hogql_val_532)s, %(hogql_val_533)s, %(hogql_val_534)s, %(hogql_val_535)s, %(hogql_val_536)s, %(hogql_val_537)s, %(hogql_val_538)s, %(hogql_val_539)s, %(hogql_val_540)s, %(hogql_val_541)s, %(hogql_val_542)s, %(hogql_val_543)s, %(hogql_val_544)s, %(hogql_val_545)s, %(hogql_val_546)s, %(hogql_val_547)s, %(hogql_val_548)s, %(hogql_val_549)s, %(hogql_val_550)s, %(hogql_val_551)s, %(hogql_val_552)s, %(hogql_val_553)s, %(hogql_val_554)s, %(hogql_val_555)s, %(hogql_val_556)s, %(hogql_val_557)s, %(hogql_val_558)s, %(hogql_val_559)s, %(hogql_val_560)s, %(hogql_val_561)s, %(hogql_val_562)s, %(hogql_val_563)s, %(hogql_val_564)s, %(hogql_val_565)s, %(hogql_val_566)s, %(hogql_val_567)s, %(hogql_val_568)s, %(hogql_val_569)s, %(hogql_val_570)s, %(hogql_val_571)s, %(hogql_val_572)s, %(hogql_val_573)s, %(hogql_val_574)s, %(hogql_val_575)s, %(hogql_val_576)s, %(hogql_val_577)s, %(hogql_val_578)s, %(hogql_val_579)s, %(hogql_val_580)s, %(hogql_val_581)s, %(hogql_val_582)s, %(hogql_val_583)s, %(hogql_val_584)s, %(hogql_val_585)s, %(hogql_val_586)s, %(hogql_val_587)s, %(hogql_val_588)s, %(hogql_val_589)s, %(hogql_val_590)s, %(hogql_val_591)s, %(hogql_val_592)s, %(hogql_val_593)s, %(hogql_val_594)s, %(hogql_val_595)s, %(hogql_val_596)s, %(hogql_val_597)s, %(hogql_val_598)s, %(hogql_val_599)s, %(hogql_val_600)s, %(hogql_val_601)s, %(hogql_val_602)s, %(hogql_val_603)s, %(hogql_val_604)s, %(hogql_val_605)s, %(hogql_val_606)s, %(hogql_val_607)s, %(hogql_val_608)s, %(hogql_val_609)s, %(hogql_val_610)s, %(hogql_val_611)s, %(hogql_val_612)s, %(hogql_val_613)s, %(hogql_val_614)s, %(hogql_val_615)s, %(hogql_val_616)s, %(hogql_val_617)s, %(hogql_val_618)s, %(hogql_val_619)s, %(hogql_val_620)s, %(hogql_val_621)s, %(hogql_val_622)s, %(hogql_val_623)s, %(hogql_val_624)s, %(hogql_val_625)s, %(hogql_val_626)s, %(hogql_val_627)s, %(hogql_val_628)s, %(hogql_val_629)s, %(hogql_val_630)s, %(hogql_val_631)s, %(hogql_val_632)s, %(hogql_val_633)s, %(hogql_val_634)s, %(hogql_val_635)s, %(hogql_val_636)s, %(hogql_val_637)s, %(hogql_val_638)s, %(hogql_val_639)s, %(hogql_val_640)s, %(hogql_val_641)s, %(hogql_val_642)s, %(hogql_val_643)s, %(hogql_val_644)s, %(hogql_val_645)s, %(hogql_val_646)s, %(hogql_val_647)s, %(hogql_val_648)s, %(hogql_val_649)s, %(hogql_val_650)s, %(hogql_val_651)s, %(hogql_val_652)s, %(hogql_val_653)s, %(hogql_val_654)s, %(hogql_val_655)s, %(hogql_val_656)s, %(hogql_val_657)s, %(hogql_val_658)s, %(hogql_val_659)s, %(hogql_val_660)s, %(hogql_val_661)s, %(hogql_val_662)s, %(hogql_val_663)s, %(hogql_val_664)s, %(hogql_val_665)s, %(hogql_val_666)s, %(hogql_val_667)s, %(hogql_val_668)s, %(hogql_val_669)s, %(hogql_val_670)s, %(hogql_val_671)s, %(hogql_val_672)s, %(hogql_val_673)s, %(hogql_val_674)s, %(hogql_val_675)s, %(hogql_val_676)s, %(hogql_val_677)s, %(hogql_val_678)s, %(hogql_val_679)s, %(hogql_val_680)s, %(hogql_val_681)s, %(hogql_val_682)s, %(hogql_val_683)s, %(hogql_val_684)s, %(hogql_val_685)s, %(hogql_val_686)s, %(hogql_val_687)s, %(hogql_val_688)s, %(hogql_val_689)s][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_690)s), [%(hogql_val_691)s, %(hogql_val_692)s, %(hogql_val_693)s, %(hogql_val_694)s, %(hogql_val_695)s, %(hogql_val_696)s, %(hogql_val_697)s, %(hogql_val_698)s, %(hogql_val_699)s, %(hogql_val_700)s, %(hogql_val_701)s, %(hogql_val_702)s, %(hogql_val_703)s, %(hogql_val_704)s, %(hogql_val_705)s, %(hogql_val_706)s, %(hogql_val_707)s, %(hogql_val_708)s, %(hogql_val_709)s, %(hogql_val_710)s, %(hogql_val_711)s, %(hogql_val_712)s, %(hogql_val_713)s, %(hogql_val_714)s, %(hogql_val_715)s, %(hogql_val_716)s, %(hogql_val_717)s, %(hogql_val_718)s, %(hogql_val_719)s, %(hogql_val_720)s, %(hogql_val_721)s, %(hogql_val_722)s, %(hogql_val_723)s, %(hogql_val_724)s, %(hogql_val_725)s, %(hogql_val_726)s, %(hogql_val_727)s, %(hogql_val_728)s, %(hogql_val_729)s, %(hogql_val_730)s, %(hogql_val_731)s, %(hogql_val_732)s, %(hogql_val_733)s, %(hogql_val_734)s, %(hogql_val_735)s, %(hogql_val_736)s, %(hogql_val_737)s, %(hogql_val_738)s, %(hogql_val_739)s, %(hogql_val_740)s, %(hogql_val_741)s, %(hogql_val_742)s, %(hogql_val_743)s, %(hogql_val_744)s, %(hogql_val_745)s, %(hogql_val_746)s, %(hogql_val_747)s, %(hogql_val_748)s, %(hogql_val_749)s, %(hogql_val_750)s, %(hogql_val_751)s, %(hogql_val_752)s, %(hogql_val_753)s, %(hogql_val_754)s, %(hogql_val_755)s, %(hogql_val_756)s, %(hogql_val_757)s, %(hogql_val_758)s, %(hogql_val_759)s, %(hogql_val_760)s, %(hogql_val_761)s, %(hogql_val_762)s, %(hogql_val_763)s, %(hogql_val_764)s, %(hogql_val_765)s, %(hogql_val_766)s, %(hogql_val_767)s, %(hogql_val_768)s, %(hogql_val_769)s, %(hogql_val_770)s, %(hogql_val_771)s, %(hogql_val_772)s, %(hogql_val_773)s, %(hogql_val_774)s, %(hogql_val_775)s, %(hogql_val_776)s, %(hogql_val_777)s, %(hogql_val_778)s, %(hogql_val_779)s, %(hogql_val_780)s, %(hogql_val_781)s, %(hogql_val_782)s, %(hogql_val_783)s, %(hogql_val_784)s, %(hogql_val_785)s, %(hogql_val_786)s, %(hogql_val_787)s, %(hogql_val_788)s, %(hogql_val_789)s, %(hogql_val_790)s, %(hogql_val_791)s, %(hogql_val_792)s, %(hogql_val_793)s, %(hogql_val_794)s, %(hogql_val_795)s, %(hogql_val_796)s, %(hogql_val_797)s, %(hogql_val_798)s, %(hogql_val_799)s, %(hogql_val_800)s, %(hogql_val_801)s, %(hogql_val_802)s, %(hogql_val_803)s, %(hogql_val_804)s, %(hogql_val_805)s, %(hogql_val_806)s, %(hogql_val_807)s, %(hogql_val_808)s, %(hogql_val_809)s, %(hogql_val_810)s, %(hogql_val_811)s, %(hogql_val_812)s, %(hogql_val_813)s, %(hogql_val_814)s, %(hogql_val_815)s, %(hogql_val_816)s, %(hogql_val_817)s, %(hogql_val_818)s, %(hogql_val_819)s, %(hogql_val_820)s, %(hogql_val_821)s, %(hogql_val_822)s, %(hogql_val_823)s, %(hogql_val_824)s, %(hogql_val_825)s, %(hogql_val_826)s, %(hogql_val_827)s, %(hogql_val_828)s, %(hogql_val_829)s, %(hogql_val_830)s, %(hogql_val_831)s, %(hogql_val_832)s, %(hogql_val_833)s, %(hogql_val_834)s, %(hogql_val_835)s, %(hogql_val_836)s, %(hogql_val_837)s, %(hogql_val_838)s, %(hogql_val_839)s, %(hogql_val_840)s, %(hogql_val_841)s, %(hogql_val_842)s, %(hogql_val_843)s, %(hogql_val_844)s, %(hogql_val_845)s, %(hogql_val_846)s, %(hogql_val_847)s, %(hogql_val_848)s, %(hogql_val_849)s, %(hogql_val_850)s, %(hogql_val_851)s, %(hogql_val_852)s, %(hogql_val_853)s, %(hogql_val_854)s, %(hogql_val_855)s, %(hogql_val_856)s, %(hogql_val_857)s, %(hogql_val_858)s, %(hogql_val_859)s, %(hogql_val_860)s, %(hogql_val_861)s, %(hogql_val_862)s, %(hogql_val_863)s, %(hogql_val_864)s, %(hogql_val_865)s, %(hogql_val_866)s, %(hogql_val_867)s, %(hogql_val_868)s, %(hogql_val_869)s, %(hogql_val_870)s, %(hogql_val_871)s, %(hogql_val_872)s, %(hogql_val_873)s, %(hogql_val_874)s, %(hogql_val_875)s, %(hogql_val_876)s, %(hogql_val_877)s, %(hogql_val_878)s, %(hogql_val_879)s, %(hogql_val_880)s, %(hogql_val_881)s, %(hogql_val_882)s, %(hogql_val_883)s, %(hogql_val_884)s, %(hogql_val_885)s, %(hogql_val_886)s, %(hogql_val_887)s, %(hogql_val_888)s, %(hogql_val_889)s, %(hogql_val_890)s, %(hogql_val_891)s, %(hogql_val_892)s, %(hogql_val_893)s, %(hogql_val_894)s, %(hogql_val_895)s, %(hogql_val_896)s, %(hogql_val_897)s, %(hogql_val_898)s, %(hogql_val_899)s, %(hogql_val_900)s, %(hogql_val_901)s, %(hogql_val_902)s, %(hogql_val_903)s, %(hogql_val_904)s, %(hogql_val_905)s, %(hogql_val_906)s, %(hogql_val_907)s, %(hogql_val_908)s, %(hogql_val_909)s, %(hogql_val_910)s, %(hogql_val_911)s, %(hogql_val_912)s, %(hogql_val_913)s, %(hogql_val_914)s, %(hogql_val_915)s, %(hogql_val_916)s, %(hogql_val_917)s, %(hogql_val_918)s, %(hogql_val_919)s, %(hogql_val_920)s, %(hogql_val_921)s, %(hogql_val_922)s, %(hogql_val_923)s, %(hogql_val_924)s, %(hogql_val_925)s, %(hogql_val_926)s, %(hogql_val_927)s, %(hogql_val_928)s, %(hogql_val_929)s, %(hogql_val_930)s, %(hogql_val_931)s, %(hogql_val_932)s, %(hogql_val_933)s, %(hogql_val_934)s, %(hogql_val_935)s, %(hogql_val_936)s, %(hogql_val_937)s, %(hogql_val_938)s, %(hogql_val_939)s, %(hogql_val_940)s, %(hogql_val_941)s, %(hogql_val_942)s, %(hogql_val_943)s, %(hogql_val_944)s, %(hogql_val_945)s, %(hogql_val_946)s, %(hogql_val_947)s, %(hogql_val_948)s, %(hogql_val_949)s, %(hogql_val_950)s, %(hogql_val_951)s, %(hogql_val_952)s, %(hogql_val_953)s, %(hogql_val_954)s, %(hogql_val_955)s, %(hogql_val_956)s, %(hogql_val_957)s, %(hogql_val_958)s, %(hogql_val_959)s, %(hogql_val_960)s, %(hogql_val_961)s, %(hogql_val_962)s, %(hogql_val_963)s, %(hogql_val_964)s, %(hogql_val_965)s, %(hogql_val_966)s, %(hogql_val_967)s, %(hogql_val_968)s, %(hogql_val_969)s, %(hogql_val_970)s, %(hogql_val_971)s, %(hogql_val_972)s, %(hogql_val_973)s, %(hogql_val_974)s, %(hogql_val_975)s, %(hogql_val_976)s, %(hogql_val_977)s, %(hogql_val_978)s, %(hogql_val_979)s, %(hogql_val_980)s, %(hogql_val_981)s, %(hogql_val_982)s, %(hogql_val_983)s, %(hogql_val_984)s, %(hogql_val_985)s, %(hogql_val_986)s, %(hogql_val_987)s, %(hogql_val_988)s, %(hogql_val_989)s, %(hogql_val_990)s, %(hogql_val_991)s, %(hogql_val_992)s, %(hogql_val_993)s, %(hogql_val_994)s, %(hogql_val_995)s, %(hogql_val_996)s, %(hogql_val_997)s, %(hogql_val_998)s, %(hogql_val_999)s, %(hogql_val_1000)s, %(hogql_val_1001)s, %(hogql_val_1002)s, %(hogql_val_1003)s, %(hogql_val_1004)s, %(hogql_val_1005)s, %(hogql_val_1006)s, %(hogql_val_1007)s, %(hogql_val_1008)s, %(hogql_val_1009)s, %(hogql_val_1010)s, %(hogql_val_1011)s, %(hogql_val_1012)s, %(hogql_val_1013)s, %(hogql_val_1014)s, %(hogql_val_1015)s, %(hogql_val_1016)s, %(hogql_val_1017)s, %(hogql_val_1018)s, %(hogql_val_1019)s, %(hogql_val_1020)s, %(hogql_val_1021)s, %(hogql_val_1022)s, %(hogql_val_1023)s, %(hogql_val_1024)s, %(hogql_val_1025)s, %(hogql_val_1026)s, %(hogql_val_1027)s, %(hogql_val_1028)s, %(hogql_val_1029)s, %(hogql_val_1030)s, %(hogql_val_1031)s, %(hogql_val_1032)s, %(hogql_val_1033)s, %(hogql_val_1034)s])]) AS traffic_type,
count() AS count
FROM
events_json AS events
@@ -159,7 +159,7 @@
'''
-- ClickHouse
SELECT
- accurateCastOrNull(ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(nullIf(toString(events.properties.`$user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$user_agent`), '[]'), '{}'), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 1), %(hogql_val_345)s) AS is_bot,
+ accurateCastOrNull(ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$user_agent`), '{}'), toJSONString(events.properties.^`$user_agent`), if(isNull(events.properties.`$user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$user_agent`), toString(events.properties.`$user_agent`)))), %(hogql_val_0)s), [%(hogql_val_1)s, %(hogql_val_2)s, %(hogql_val_3)s, %(hogql_val_4)s, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s, %(hogql_val_8)s, %(hogql_val_9)s, %(hogql_val_10)s, %(hogql_val_11)s, %(hogql_val_12)s, %(hogql_val_13)s, %(hogql_val_14)s, %(hogql_val_15)s, %(hogql_val_16)s, %(hogql_val_17)s, %(hogql_val_18)s, %(hogql_val_19)s, %(hogql_val_20)s, %(hogql_val_21)s, %(hogql_val_22)s, %(hogql_val_23)s, %(hogql_val_24)s, %(hogql_val_25)s, %(hogql_val_26)s, %(hogql_val_27)s, %(hogql_val_28)s, %(hogql_val_29)s, %(hogql_val_30)s, %(hogql_val_31)s, %(hogql_val_32)s, %(hogql_val_33)s, %(hogql_val_34)s, %(hogql_val_35)s, %(hogql_val_36)s, %(hogql_val_37)s, %(hogql_val_38)s, %(hogql_val_39)s, %(hogql_val_40)s, %(hogql_val_41)s, %(hogql_val_42)s, %(hogql_val_43)s, %(hogql_val_44)s, %(hogql_val_45)s, %(hogql_val_46)s, %(hogql_val_47)s, %(hogql_val_48)s, %(hogql_val_49)s, %(hogql_val_50)s, %(hogql_val_51)s, %(hogql_val_52)s, %(hogql_val_53)s, %(hogql_val_54)s, %(hogql_val_55)s, %(hogql_val_56)s, %(hogql_val_57)s, %(hogql_val_58)s, %(hogql_val_59)s, %(hogql_val_60)s, %(hogql_val_61)s, %(hogql_val_62)s, %(hogql_val_63)s, %(hogql_val_64)s, %(hogql_val_65)s, %(hogql_val_66)s, %(hogql_val_67)s, %(hogql_val_68)s, %(hogql_val_69)s, %(hogql_val_70)s, %(hogql_val_71)s, %(hogql_val_72)s, %(hogql_val_73)s, %(hogql_val_74)s, %(hogql_val_75)s, %(hogql_val_76)s, %(hogql_val_77)s, %(hogql_val_78)s, %(hogql_val_79)s, %(hogql_val_80)s, %(hogql_val_81)s, %(hogql_val_82)s, %(hogql_val_83)s, %(hogql_val_84)s, %(hogql_val_85)s, %(hogql_val_86)s, %(hogql_val_87)s, %(hogql_val_88)s, %(hogql_val_89)s, %(hogql_val_90)s, %(hogql_val_91)s, %(hogql_val_92)s, %(hogql_val_93)s, %(hogql_val_94)s, %(hogql_val_95)s, %(hogql_val_96)s, %(hogql_val_97)s, %(hogql_val_98)s, %(hogql_val_99)s, %(hogql_val_100)s, %(hogql_val_101)s, %(hogql_val_102)s, %(hogql_val_103)s, %(hogql_val_104)s, %(hogql_val_105)s, %(hogql_val_106)s, %(hogql_val_107)s, %(hogql_val_108)s, %(hogql_val_109)s, %(hogql_val_110)s, %(hogql_val_111)s, %(hogql_val_112)s, %(hogql_val_113)s, %(hogql_val_114)s, %(hogql_val_115)s, %(hogql_val_116)s, %(hogql_val_117)s, %(hogql_val_118)s, %(hogql_val_119)s, %(hogql_val_120)s, %(hogql_val_121)s, %(hogql_val_122)s, %(hogql_val_123)s, %(hogql_val_124)s, %(hogql_val_125)s, %(hogql_val_126)s, %(hogql_val_127)s, %(hogql_val_128)s, %(hogql_val_129)s, %(hogql_val_130)s, %(hogql_val_131)s, %(hogql_val_132)s, %(hogql_val_133)s, %(hogql_val_134)s, %(hogql_val_135)s, %(hogql_val_136)s, %(hogql_val_137)s, %(hogql_val_138)s, %(hogql_val_139)s, %(hogql_val_140)s, %(hogql_val_141)s, %(hogql_val_142)s, %(hogql_val_143)s, %(hogql_val_144)s, %(hogql_val_145)s, %(hogql_val_146)s, %(hogql_val_147)s, %(hogql_val_148)s, %(hogql_val_149)s, %(hogql_val_150)s, %(hogql_val_151)s, %(hogql_val_152)s, %(hogql_val_153)s, %(hogql_val_154)s, %(hogql_val_155)s, %(hogql_val_156)s, %(hogql_val_157)s, %(hogql_val_158)s, %(hogql_val_159)s, %(hogql_val_160)s, %(hogql_val_161)s, %(hogql_val_162)s, %(hogql_val_163)s, %(hogql_val_164)s, %(hogql_val_165)s, %(hogql_val_166)s, %(hogql_val_167)s, %(hogql_val_168)s, %(hogql_val_169)s, %(hogql_val_170)s, %(hogql_val_171)s, %(hogql_val_172)s, %(hogql_val_173)s, %(hogql_val_174)s, %(hogql_val_175)s, %(hogql_val_176)s, %(hogql_val_177)s, %(hogql_val_178)s, %(hogql_val_179)s, %(hogql_val_180)s, %(hogql_val_181)s, %(hogql_val_182)s, %(hogql_val_183)s, %(hogql_val_184)s, %(hogql_val_185)s, %(hogql_val_186)s, %(hogql_val_187)s, %(hogql_val_188)s, %(hogql_val_189)s, %(hogql_val_190)s, %(hogql_val_191)s, %(hogql_val_192)s, %(hogql_val_193)s, %(hogql_val_194)s, %(hogql_val_195)s, %(hogql_val_196)s, %(hogql_val_197)s, %(hogql_val_198)s, %(hogql_val_199)s, %(hogql_val_200)s, %(hogql_val_201)s, %(hogql_val_202)s, %(hogql_val_203)s, %(hogql_val_204)s, %(hogql_val_205)s, %(hogql_val_206)s, %(hogql_val_207)s, %(hogql_val_208)s, %(hogql_val_209)s, %(hogql_val_210)s, %(hogql_val_211)s, %(hogql_val_212)s, %(hogql_val_213)s, %(hogql_val_214)s, %(hogql_val_215)s, %(hogql_val_216)s, %(hogql_val_217)s, %(hogql_val_218)s, %(hogql_val_219)s, %(hogql_val_220)s, %(hogql_val_221)s, %(hogql_val_222)s, %(hogql_val_223)s, %(hogql_val_224)s, %(hogql_val_225)s, %(hogql_val_226)s, %(hogql_val_227)s, %(hogql_val_228)s, %(hogql_val_229)s, %(hogql_val_230)s, %(hogql_val_231)s, %(hogql_val_232)s, %(hogql_val_233)s, %(hogql_val_234)s, %(hogql_val_235)s, %(hogql_val_236)s, %(hogql_val_237)s, %(hogql_val_238)s, %(hogql_val_239)s, %(hogql_val_240)s, %(hogql_val_241)s, %(hogql_val_242)s, %(hogql_val_243)s, %(hogql_val_244)s, %(hogql_val_245)s, %(hogql_val_246)s, %(hogql_val_247)s, %(hogql_val_248)s, %(hogql_val_249)s, %(hogql_val_250)s, %(hogql_val_251)s, %(hogql_val_252)s, %(hogql_val_253)s, %(hogql_val_254)s, %(hogql_val_255)s, %(hogql_val_256)s, %(hogql_val_257)s, %(hogql_val_258)s, %(hogql_val_259)s, %(hogql_val_260)s, %(hogql_val_261)s, %(hogql_val_262)s, %(hogql_val_263)s, %(hogql_val_264)s, %(hogql_val_265)s, %(hogql_val_266)s, %(hogql_val_267)s, %(hogql_val_268)s, %(hogql_val_269)s, %(hogql_val_270)s, %(hogql_val_271)s, %(hogql_val_272)s, %(hogql_val_273)s, %(hogql_val_274)s, %(hogql_val_275)s, %(hogql_val_276)s, %(hogql_val_277)s, %(hogql_val_278)s, %(hogql_val_279)s, %(hogql_val_280)s, %(hogql_val_281)s, %(hogql_val_282)s, %(hogql_val_283)s, %(hogql_val_284)s, %(hogql_val_285)s, %(hogql_val_286)s, %(hogql_val_287)s, %(hogql_val_288)s, %(hogql_val_289)s, %(hogql_val_290)s, %(hogql_val_291)s, %(hogql_val_292)s, %(hogql_val_293)s, %(hogql_val_294)s, %(hogql_val_295)s, %(hogql_val_296)s, %(hogql_val_297)s, %(hogql_val_298)s, %(hogql_val_299)s, %(hogql_val_300)s, %(hogql_val_301)s, %(hogql_val_302)s, %(hogql_val_303)s, %(hogql_val_304)s, %(hogql_val_305)s, %(hogql_val_306)s, %(hogql_val_307)s, %(hogql_val_308)s, %(hogql_val_309)s, %(hogql_val_310)s, %(hogql_val_311)s, %(hogql_val_312)s, %(hogql_val_313)s, %(hogql_val_314)s, %(hogql_val_315)s, %(hogql_val_316)s, %(hogql_val_317)s, %(hogql_val_318)s, %(hogql_val_319)s, %(hogql_val_320)s, %(hogql_val_321)s, %(hogql_val_322)s, %(hogql_val_323)s, %(hogql_val_324)s, %(hogql_val_325)s, %(hogql_val_326)s, %(hogql_val_327)s, %(hogql_val_328)s, %(hogql_val_329)s, %(hogql_val_330)s, %(hogql_val_331)s, %(hogql_val_332)s, %(hogql_val_333)s, %(hogql_val_334)s, %(hogql_val_335)s, %(hogql_val_336)s, %(hogql_val_337)s, %(hogql_val_338)s, %(hogql_val_339)s, %(hogql_val_340)s, %(hogql_val_341)s, %(hogql_val_342)s, %(hogql_val_343)s, %(hogql_val_344)s]), 0), 1), %(hogql_val_345)s) AS is_bot,
count() AS count
FROM
events_json AS events
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_bots.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_bots.new_events_schema.ambr
index d94ebd37769e..1a306d94b362 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_bots.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_bots.new_events_schema.ambr
@@ -1,12 +1,12 @@
# serializer version: 1
# name: TestWebBotsTableQueryRunner.test_date_range_excludes_outside_events[new_events_schema]
'''
- SELECT if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Crawler,
- if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Category,
+ SELECT if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Crawler,
+ if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Category,
count() AS Requests,
max(toTimeZone(events.timestamp, 'UTC')) AS `Last seen`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(ifNull(equals(accurateCastOrNull(or(and(not(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0))), ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 1)), or(/* bot ip ranges */)), 'Bool'), 1), 0), notEquals(if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])), ''), in(events.event, tuple('$pageview', '$screen', '$http_log')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-03-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-03-31 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(ifNull(equals(accurateCastOrNull(or(and(not(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0))), ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 1)), or(/* bot ip ranges */)), 'Bool'), 1), 0), notEquals(if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])), ''), in(events.event, tuple('$pageview', '$screen', '$http_log')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-03-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-03-31 23:59:59', 'UTC')))), 0), 1))
GROUP BY Crawler,
Category
ORDER BY Requests DESC
@@ -29,12 +29,12 @@
# ---
# name: TestWebBotsTableQueryRunner.test_only_bot_traffic_grouped_by_breakdown_0_Crawler[new_events_schema]
'''
- SELECT if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Crawler,
- if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Category,
+ SELECT if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Crawler,
+ if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), 'regular', ['search_crawler', 'search_crawler', 'search_crawler', 'ai_assistant', 'ai_search', 'ai_crawler', 'ai_assistant', 'ai_search', 'search_crawler', 'ai_search', 'seo_crawler'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])) AS Category,
count() AS Requests,
max(toTimeZone(events.timestamp, 'UTC')) AS `Last seen`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(ifNull(equals(accurateCastOrNull(or(and(not(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0))), ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 1)), or(/* bot ip ranges */)), 'Bool'), 1), 0), notEquals(if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])), ''), in(events.event, tuple('$pageview', '$screen', '$http_log')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-31 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(ifNull(equals(accurateCastOrNull(or(and(not(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0))), ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 1)), or(/* bot ip ranges */)), 'Bool'), 1), 0), notEquals(if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])), ''), in(events.event, tuple('$pageview', '$screen', '$http_log')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-31 23:59:59', 'UTC')))), 0), 1))
GROUP BY Crawler,
Category
ORDER BY Requests DESC
@@ -57,12 +57,12 @@
# ---
# name: TestWebBotsTableQueryRunner.test_only_bot_traffic_grouped_by_breakdown_1_Path[new_events_schema]
'''
- SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS Path,
- count(DISTINCT if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])]))) AS Crawlers,
+ SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS Path,
+ count(DISTINCT if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])]))) AS Crawlers,
count() AS Requests,
max(toTimeZone(events.timestamp, 'UTC')) AS `Last seen`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(ifNull(equals(accurateCastOrNull(or(and(not(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0))), ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 1)), or(/* bot ip ranges */)), 'Bool'), 1), 0), notEquals(if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(nullIf(toString(events.properties.`$raw_user_agent`), '')), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$raw_user_agent`), '[]'), '{}'), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])), ''), in(events.event, tuple('$pageview', '$screen', '$http_log')), isNotNull(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-31 23:59:59', 'UTC')))), 0), 1))
+ WHERE and(equals(events.team_id, 99999), and(ifNull(equals(accurateCastOrNull(or(and(not(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0))), ifNull(notEquals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 1)), or(/* bot ip ranges */)), 'Bool'), 1), 0), notEquals(if(and(in(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$lib`), '{}'), toJSONString(events.properties.^`$lib`), if(isNull(nullIf(toString(events.properties.`$lib`), '')), NULL, if(and(in(ascii(toString(events.properties.`$lib`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$lib`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$lib`), '[]'), '{}'), toString(events.properties.`$lib`))))), ''), tuple('posthog-node', 'posthog-node-mcp', 'posthog-edge', 'posthog-convex', 'posthog-python', 'posthog-python-mcp', 'posthog-ruby', 'posthog-rails', 'posthog-go', 'posthog-php', 'posthog-java', 'posthog-server', 'posthog-dotnet', 'posthog-aspnetcore', 'posthog-elixir', 'posthog-rs', 'posthog-roblox', 'posthog-ios', 'posthog-android', 'posthog-react-native', 'posthog-flutter', 'posthog-kmp', 'posthog-unity')), ifNull(equals(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), ''), 0)), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), if(ifNull(equals(multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */]), 0), 0), if(equals(multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0), 0), '', ['Googlebot', 'Google special crawler', 'Google fetcher', 'ChatGPT', 'OpenAI Search', 'GPTBot', 'Perplexity User', 'Perplexity', 'Bingbot', 'Applebot', 'Ahrefs'][multiIf(or(/* bot ip ranges */), 1, or(/* bot ip ranges */), 2, or(/* bot ip ranges */), 3, or(/* bot ip ranges */), 4, or(/* bot ip ranges */), 5, or(/* bot ip ranges */), 6, or(/* bot ip ranges */), 7, or(/* bot ip ranges */), 8, or(/* bot ip ranges */), 9, or(/* bot ip ranges */), 10, or(/* bot ip ranges */), 11, 0)]), [/* 344 bot literals */][multiMatchAnyIndex(ifNull(if(notEquals(toJSONString(events.properties.^`$raw_user_agent`), '{}'), toJSONString(events.properties.^`$raw_user_agent`), if(isNull(events.properties.`$raw_user_agent`), NULL, if(and(in(ascii(toString(events.properties.`$raw_user_agent`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$raw_user_agent`)), tuple(91, 123))), toJSONString(events.properties.`$raw_user_agent`), toString(events.properties.`$raw_user_agent`)))), ''), [/* 344 bot literals */])])), ''), in(events.event, tuple('$pageview', '$screen', '$http_log')), isNotNull(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2026-01-31 23:59:59', 'UTC')))), 0), 1))
GROUP BY Path
ORDER BY Requests DESC
LIMIT 51
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.new_events_schema.ambr
index 5cdebd4de608..c203612888a6 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.new_events_schema.ambr
@@ -21,20 +21,20 @@
FROM
(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS web_goals_person_id,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?data\\-node\\-key="interactions"(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
- (SELECT cohortpeople.person_id AS person_id
- FROM cohortpeople
- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))
- GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
- HAVING greater(sum(cohortpeople.sign), 0)))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_0,
+ countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?data\\-node\\-key="interactions"(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
+ (SELECT cohortpeople.person_id AS person_id
+ FROM cohortpeople
+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))
+ GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
+ HAVING greater(sum(cohortpeople.sign), 0)))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_0,
countIf(0) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
countIf(0) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
- countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-input(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_2,
+ countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-input(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_2,
countIf(0) AS action_previous_count_2,
if(greater(action_current_count_2, 0), web_goals_person_id, NULL) AS action_current_person_id_2,
if(greater(action_previous_count_2, 0), web_goals_person_id, NULL) AS action_previous_person_id_2,
@@ -60,12 +60,12 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
- WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?data\\-node\\-key="interactions"(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
- (SELECT cohortpeople.person_id AS person_id
- FROM cohortpeople
- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))
- GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
- HAVING greater(sum(cohortpeople.sign), 0)))), and(equals(events.event, '$pageview'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-input(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-btn\\.(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?text\\-white(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), arrayExists(x -> ifNull(equals(x, 'text page'), 0), events.elements_chain_texts), ifNull(equals(CAST(events.properties.`$current_url`, 'Nullable(String)'), 'https://teest.com'), 0)), and(equals(events.event, '$autocapture'), and(match(events.elements_chain, '(^|;)a(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))(?:(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*;)*(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-btn(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), greater(arrayCount(x -> in(x, ['a']), events.elements_chain_elements), 0)), arrayExists(x -> ifNull(equals(x, 'text'), 0), events.elements_chain_texts), ifNull(equals(CAST(events.properties.`$current_url`, 'Nullable(String)'), 'https://teest.com'), 0)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), and(ifNull(equals(CAST(events.properties.`mat_$host`, 'Nullable(String)'), 'teest.com'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`mat_$current_url`), '{}'), toJSONString(events.properties.^`mat_$current_url`), if(isNull(nullIf(toString(events.properties.`mat_$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`mat_$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`mat_$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`mat_$current_url`), '[]'), '{}'), toString(events.properties.`mat_$current_url`))))), '%https://teest.com%'), 0)), 1))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?data\\-node\\-key="interactions"(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),
+ (SELECT cohortpeople.person_id AS person_id
+ FROM cohortpeople
+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))
+ GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
+ HAVING greater(sum(cohortpeople.sign), 0)))), and(equals(events.event, '$pageview'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-input(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-btn\\.(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?text\\-white(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), arrayExists(x -> ifNull(equals(x, 'text page'), 0), events.elements_chain_texts), ifNull(equals(CAST(events.properties.`$current_url`, 'Nullable(String)'), 'https://teest.com'), 0)), and(equals(events.event, '$autocapture'), and(match(events.elements_chain, '(^|;)a(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))(?:(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*;)*(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?\\.ant\\-btn(?:[^;"]|"(?:\\\\.|[^"\\\\])*")*?($|;|:([^;^\\s]*(;|$|\\s)))'), greater(arrayCount(x -> in(x, ['a']), events.elements_chain_elements), 0)), arrayExists(x -> ifNull(equals(x, 'text'), 0), events.elements_chain_texts), ifNull(equals(CAST(events.properties.`$current_url`, 'Nullable(String)'), 'https://teest.com'), 0)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), and(ifNull(equals(CAST(events.properties.`mat_$host`, 'Nullable(String)'), 'teest.com'), 0), ifNull(ilike(toString(if(notEquals(toJSONString(events.properties.^`mat_$current_url`), '{}'), toJSONString(events.properties.^`mat_$current_url`), if(isNull(events.properties.`mat_$current_url`), NULL, if(and(in(ascii(toString(events.properties.`mat_$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`mat_$current_url`)), tuple(91, 123))), toJSONString(events.properties.`mat_$current_url`), toString(events.properties.`mat_$current_url`))))), '%https://teest.com%'), 0)), 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0)
LIMIT 100 SETTINGS readonly=2,
@@ -101,9 +101,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1
@@ -121,7 +121,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
@@ -161,9 +161,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
@@ -185,7 +185,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
@@ -225,7 +225,7 @@
countIf(0) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
countIf(0) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
@@ -248,7 +248,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0)
@@ -288,9 +288,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
@@ -312,7 +312,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
@@ -352,9 +352,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
@@ -376,7 +376,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
@@ -416,9 +416,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
@@ -440,7 +440,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
@@ -480,9 +480,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
@@ -504,7 +504,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
@@ -544,9 +544,9 @@
countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_0,
if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,
if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_1,
- countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))) AS action_previous_count_1,
if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,
if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,
@@ -568,7 +568,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Contacted Sales'), 0), events.elements_chain_texts)), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://(app|eu|us)\\.posthog\\.com/project/\\d+/web.*'))), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;)button(\\.|$|;|:)'), arrayExists(x -> ifNull(equals(x, 'Pay $10'), 0), events.elements_chain_texts)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC'))))), 1, 1))
GROUP BY events.properties.`$session_id`)
WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-11-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-08-03 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2024-10-31 23:59:59', 'UTC')))))
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.new_events_schema.ambr
index 2863bb75c557..b7cc8c53e57f 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_overview.new_events_schema.ambr
@@ -167,7 +167,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(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/bar'))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-30 23:59:59', 'UTC'))))), 1))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -512,7 +512,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(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-30 23:59:59', 'UTC'))))), 1))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -599,7 +599,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(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-30 23:59:59', 'UTC'))))), 1))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -1098,7 +1098,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(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-30 23:59:59', 'UTC'))))), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-30 23:59:59', 'UTC'))))), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
GROUP BY session_id
HAVING or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-11-30 23:59:59', 'UTC'))))))
LIMIT 100 SETTINGS readonly=2,
@@ -1212,7 +1212,7 @@
WHERE and(equals(events.team_id, 99999), and(isNotNull(events.properties.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-30 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -2054,7 +2054,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(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-30 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-07 23:59:59', 'UTC'))))), 1))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
@@ -2141,7 +2141,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(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`))), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), 1))
LIMIT 100 SETTINGS readonly=2,
max_execution_time=60,
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.new_events_schema.ambr
index 8730844bfbc3..8fe166f2af35 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.new_events_schema.ambr
@@ -8,7 +8,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -83,7 +83,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -106,13 +106,13 @@
breakdown_value)
GROUP BY breakdown_value) AS counts
LEFT JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-06 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-13 23:59:59', 'UTC'))))) AS avg_time_on_page,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-05 23:59:59', 'UTC'))))) AS previous_avg_time_on_page
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_duration`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_duration`), '[]'), '{}'), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-06 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-13 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-05 23:59:59', 'UTC'))))), 1, 1))
+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(events.properties.`$prev_pageview_duration`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_duration`), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-06 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-13 23:59:59', 'UTC')))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-11-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-05 23:59:59', 'UTC'))))), 1, 1))
GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)
LEFT JOIN
(SELECT breakdown_value AS breakdown_value,
@@ -175,7 +175,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -198,13 +198,13 @@
breakdown_value)
GROUP BY breakdown_value) AS counts
LEFT JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))))) AS avg_time_on_page,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
0) AS previous_avg_time_on_page
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_duration`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_duration`), '[]'), '{}'), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(events.properties.`$prev_pageview_duration`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_duration`), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)
LEFT JOIN
(SELECT breakdown_value AS breakdown_value,
@@ -289,7 +289,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -312,13 +312,13 @@
breakdown_value)
GROUP BY breakdown_value) AS counts
LEFT JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))))) AS avg_time_on_page,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
0) AS previous_avg_time_on_page
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_duration`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_duration`), '[]'), '{}'), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(events.properties.`$prev_pageview_duration`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_duration`), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)
LEFT JOIN
(SELECT breakdown_value AS breakdown_value,
@@ -403,7 +403,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -426,13 +426,13 @@
breakdown_value)
GROUP BY breakdown_value) AS counts
LEFT JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))))) AS avg_time_on_page,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
0) AS previous_avg_time_on_page
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_duration`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_duration`), '[]'), '{}'), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(events.properties.`$prev_pageview_duration`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_duration`), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)
LEFT JOIN
(SELECT breakdown_value AS breakdown_value,
@@ -516,7 +516,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -620,7 +620,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -724,7 +724,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/a\\/\\d+', '/a/:id'), '\\/b\\/\\d+', '/b/:id'), '\\/c\\/\\d+', '/c/:id') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/a\\/\\d+', '/a/:id'), '\\/b\\/\\d+', '/b/:id'), '\\/c\\/\\d+', '/c/:id') AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -828,7 +828,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -932,7 +932,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -1084,7 +1084,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -1154,7 +1154,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -1201,13 +1201,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/bar')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/bar'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -1225,7 +1225,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/bar'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/bar')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -1440,13 +1440,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -1464,7 +1464,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -1502,13 +1502,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -1526,7 +1526,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -1564,13 +1564,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -1588,7 +1588,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), 'https://www.example.com/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('https://www.example.com/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -1624,7 +1624,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -1981,7 +1981,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -1992,7 +1992,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
GROUP BY session_id,
breakdown_value)
GROUP BY `context.columns.breakdown_value`
@@ -2032,7 +2032,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2082,7 +2082,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2153,7 +2153,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2333,7 +2333,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2382,7 +2382,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2458,7 +2458,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp,
countIf(equals(events.event, 'custom_event')) AS conversion_count,
@@ -2641,7 +2641,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2690,7 +2690,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2762,7 +2762,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2776,7 +2776,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -2896,7 +2896,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -2910,7 +2910,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -3028,7 +3028,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3042,7 +3042,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -3160,7 +3160,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3174,7 +3174,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -3238,7 +3238,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3252,7 +3252,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -3316,7 +3316,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3330,7 +3330,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -3394,7 +3394,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3465,7 +3465,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3479,7 +3479,7 @@
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), globalIn(events.properties.`$session_id`,
(SELECT session_id AS session_id
FROM
- (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
+ (SELECT events.properties.`$session_id` AS session_id, argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 10:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNotNull(toUInt128(toUUIDOrNull(events.properties.`$session_id`)))))
GROUP BY session_id)
@@ -3543,7 +3543,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3615,7 +3615,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3687,7 +3687,7 @@
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,
- argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(nullIf(toString(events.properties.utm_campaign), '')), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_campaign), '[]'), '{}'), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(nullIf(toString(events.properties.utm_medium), '')), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_medium), '[]'), '{}'), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(nullIf(toString(events.properties.`$referring_domain`), '')), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$referring_domain`), '[]'), '{}'), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(nullIf(toString(events.properties.gclid), '')), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gclid), '[]'), '{}'), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(nullIf(toString(events.properties.fbclid), '')), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.fbclid), '[]'), '{}'), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(nullIf(toString(events.properties.gad_source), '')), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.gad_source), '[]'), '{}'), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
+ argMinIf(tuple(if(notEquals(toJSONString(events.properties.^utm_campaign), '{}'), toJSONString(events.properties.^utm_campaign), if(isNull(events.properties.utm_campaign), NULL, if(and(in(ascii(toString(events.properties.utm_campaign)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_campaign)), tuple(91, 123))), toJSONString(events.properties.utm_campaign), toString(events.properties.utm_campaign)))), if(notEquals(toJSONString(events.properties.^utm_medium), '{}'), toJSONString(events.properties.^utm_medium), if(isNull(events.properties.utm_medium), NULL, if(and(in(ascii(toString(events.properties.utm_medium)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_medium)), tuple(91, 123))), toJSONString(events.properties.utm_medium), toString(events.properties.utm_medium)))), if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))), if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), if(notEquals(toJSONString(events.properties.^`$referring_domain`), '{}'), toJSONString(events.properties.^`$referring_domain`), if(isNull(events.properties.`$referring_domain`), NULL, if(and(in(ascii(toString(events.properties.`$referring_domain`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$referring_domain`)), tuple(91, 123))), toJSONString(events.properties.`$referring_domain`), toString(events.properties.`$referring_domain`)))), if(notEquals(toJSONString(events.properties.^gclid), '{}'), toJSONString(events.properties.^gclid), if(isNull(events.properties.gclid), NULL, if(and(in(ascii(toString(events.properties.gclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gclid)), tuple(91, 123))), toJSONString(events.properties.gclid), toString(events.properties.gclid)))), if(notEquals(toJSONString(events.properties.^fbclid), '{}'), toJSONString(events.properties.^fbclid), if(isNull(events.properties.fbclid), NULL, if(and(in(ascii(toString(events.properties.fbclid)), tuple(91, 123)), in(ascii(toJSONString(events.properties.fbclid)), tuple(91, 123))), toJSONString(events.properties.fbclid), toString(events.properties.fbclid)))), if(notEquals(toJSONString(events.properties.^gad_source), '{}'), toJSONString(events.properties.^gad_source), if(isNull(events.properties.gad_source), NULL, if(and(in(ascii(toString(events.properties.gad_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.gad_source)), tuple(91, 123))), toJSONString(events.properties.gad_source), toString(events.properties.gad_source))))), toTimeZone(events.timestamp, 'UTC'), in(events.event, tuple('$pageview', '$screen'))) AS first_pageview_properties,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3753,7 +3753,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$webview_app`), '{}'), toJSONString(events.properties.^`$webview_app`), if(isNull(nullIf(toString(events.properties.`$webview_app`), '')), NULL, if(and(in(ascii(toString(events.properties.`$webview_app`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$webview_app`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$webview_app`), '[]'), '{}'), toString(events.properties.`$webview_app`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$webview_app`), '{}'), toJSONString(events.properties.^`$webview_app`), if(isNull(events.properties.`$webview_app`), NULL, if(and(in(ascii(toString(events.properties.`$webview_app`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$webview_app`)), tuple(91, 123))), toJSONString(events.properties.`$webview_app`), toString(events.properties.`$webview_app`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -3798,7 +3798,7 @@
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(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), ''), ifNull(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '')), '') AS breakdown_value,
+ nullIf(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))), ''), ifNull(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '')), '') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4099,7 +4099,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4399,7 +4399,7 @@
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(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), ''), ifNull(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))), '')), '') AS breakdown_value,
+ nullIf(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))), ''), ifNull(toString(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))), '')), '') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4444,7 +4444,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4511,7 +4511,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4556,7 +4556,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(nullIf(toString(events.properties.`$screen_name`), '')), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$screen_name`), '[]'), '{}'), toString(events.properties.`$screen_name`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$screen_name`), '{}'), toJSONString(events.properties.^`$screen_name`), if(isNull(events.properties.`$screen_name`), NULL, if(and(in(ascii(toString(events.properties.`$screen_name`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$screen_name`)), tuple(91, 123))), toJSONString(events.properties.`$screen_name`), toString(events.properties.`$screen_name`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4622,7 +4622,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-06-26 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNull(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(nullIf(toString(events.properties.utm_source), '')), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.utm_source), '[]'), '{}'), toString(events.properties.utm_source)))))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-26 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-06-27 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), isNull(if(notEquals(toJSONString(events.properties.^utm_source), '{}'), toJSONString(events.properties.^utm_source), if(isNull(events.properties.utm_source), NULL, if(and(in(ascii(toString(events.properties.utm_source)), tuple(91, 123)), in(ascii(toJSONString(events.properties.utm_source)), tuple(91, 123))), toJSONString(events.properties.utm_source), toString(events.properties.utm_source)))))))
GROUP BY session_id,
breakdown_value)
GROUP BY `context.columns.breakdown_value`
@@ -4689,7 +4689,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-07-30 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(nullIf(toString(events.person_properties.email), '')), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.person_properties.email), '[]'), '{}'), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2024-07-30 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(notILike(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(and(in(ascii(toString(events.person_properties.email)), tuple(91, 123)), in(ascii(toJSONString(events.person_properties.email)), tuple(91, 123))), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), '%@posthog.com%'), 1)))
GROUP BY session_id,
breakdown_value)
GROUP BY `context.columns.breakdown_value`
@@ -4744,7 +4744,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4789,7 +4789,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -4856,7 +4856,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5011,7 +5011,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5162,7 +5162,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -5185,13 +5185,13 @@
breakdown_value)
GROUP BY breakdown_value) AS counts
LEFT JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))))) AS avg_time_on_page,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
0) AS previous_avg_time_on_page
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_duration`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_duration`), '[]'), '{}'), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(events.properties.`$prev_pageview_duration`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_duration`), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)
LEFT JOIN
(SELECT breakdown_value AS breakdown_value,
@@ -5268,7 +5268,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5335,7 +5335,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/admin\\/settings\\/.*', '/admin/settings/<page>'), '\\/admin\\/.*', '/admin/<section>'), '\\/user\\/\\d+\\/.*', '/user/<id>/<page>') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/admin\\/settings\\/.*', '/admin/settings/<page>'), '\\/admin\\/.*', '/admin/<section>'), '\\/user\\/\\d+\\/.*', '/user/<id>/<page>') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5402,7 +5402,7 @@
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,
- replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/item\\/(\\d+)\\/detail\\/\\d+', '/item/\\1') AS breakdown_value,
+ replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/item\\/(\\d+)\\/detail\\/\\d+', '/item/\\1') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5469,7 +5469,7 @@
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,
- replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id') AS breakdown_value,
+ replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5480,7 +5480,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('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(equals(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), replaceRegexpAll('/cleaned/123456', '\\/cleaned\\/\\d+', '/cleaned/:id')), isNull(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(equals(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), replaceRegexpAll('/cleaned/123456', '\\/cleaned\\/\\d+', '/cleaned/:id')), isNull(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'))
and isNull(replaceRegexpAll('/cleaned/123456', '\\/cleaned\\/\\d+', '/cleaned/:id')))))
GROUP BY session_id,
breakdown_value)
@@ -5537,7 +5537,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5548,7 +5548,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('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(equals(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'), replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')), isNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(equals(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'), replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')), isNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))
and isNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')))))
GROUP BY session_id,
breakdown_value)
@@ -5583,7 +5583,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5594,7 +5594,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('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(equals(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'), replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/123456', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')), isNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), ifNull(equals(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'), replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/123456', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')), isNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))
and isNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/123456', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')))))
GROUP BY session_id,
breakdown_value)
@@ -5629,7 +5629,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5640,8 +5640,8 @@
WHERE equals(person_distinct_id_overrides.team_id, 99999)
GROUP BY person_distinct_id_overrides.distinct_id
HAVING equals(argMax(person_distinct_id_overrides.is_deleted, 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('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(ifNull(notEquals(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'), replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')), isNotNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))
- or isNotNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))), isNull(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`))))))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(ifNull(notEquals(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'), replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c')), isNotNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))
+ or isNotNull(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll('/cleaned/:id', '\\/cleaned\\/\\d+', '/cleaned/:id'), '\\/path\\/\\d+', '/path/:id'), 'thing_a', 'thing_b'), 'thing_b', 'thing_c'))), isNull(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`))))))))
GROUP BY session_id,
breakdown_value)
GROUP BY `context.columns.breakdown_value`
@@ -5697,7 +5697,7 @@
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,
- replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/item\\/(\\d+)\\/detail\\/(\\d+)', '/item/<id>/detail/<detail_id>') AS breakdown_value,
+ replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/item\\/(\\d+)\\/detail\\/(\\d+)', '/item/<id>/detail/<detail_id>') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5764,7 +5764,7 @@
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,
- replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '/item/(\\d+)/list/(\\d+)/spp/insessionForm/(\\d+)', '/item/<id>/list/<list_id>/spp/insessionForm/<form>'), '/item/(\\d+)/detail1/(\\d+)', '/item/<id>/detail1/<consultation>'), '/item/(\\d+)/list/(\\d+)', '/item/<id>/list/<list_id>'), '/item/(\\d+)', '/item/<id>') AS breakdown_value,
+ replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '/item/(\\d+)/list/(\\d+)/spp/insessionForm/(\\d+)', '/item/<id>/list/<list_id>/spp/insessionForm/<form>'), '/item/(\\d+)/detail1/(\\d+)', '/item/<id>/detail1/<consultation>'), '/item/(\\d+)/list/(\\d+)', '/item/<id>/list/<list_id>'), '/item/(\\d+)', '/item/<id>') AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5885,7 +5885,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -5937,7 +5937,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -6041,7 +6041,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -6124,7 +6124,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -6224,13 +6224,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -6248,7 +6248,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -6287,13 +6287,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -6311,7 +6311,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -6350,13 +6350,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -6374,7 +6374,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -6412,13 +6412,13 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
any(events__session.`$is_bounce`) AS is_bounce,
min(events__session.`$start_timestamp`) AS start_timestamp,
- countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ countIf(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))) AS conversion_count,
- any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ any(if(and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo'))), if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), NULL)) AS conversion_person_id
FROM events_json AS events
LEFT JOIN
@@ -6436,7 +6436,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('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(nullIf(toString(events.properties.`$current_url`), '')), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$current_url`), '[]'), '{}'), toString(events.properties.`$current_url`)))))
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-03 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), and(equals(events.event, '$pageview'), ifNull(match(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))), '/foo'), isNull(if(notEquals(toJSONString(events.properties.^`$current_url`), '{}'), toJSONString(events.properties.^`$current_url`), if(isNull(events.properties.`$current_url`), NULL, if(and(in(ascii(toString(events.properties.`$current_url`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$current_url`)), tuple(91, 123))), toJSONString(events.properties.`$current_url`), toString(events.properties.`$current_url`)))))
and isNull('/foo')))), 1))
GROUP BY session_id,
breakdown_value)
@@ -6472,7 +6472,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -6517,7 +6517,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -6584,7 +6584,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -6629,7 +6629,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), events.properties.`$session_id`, NULL) AS session_id,
any(if(ifNull(equals(bitAnd(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(toUInt128(toUUIDOrNull(events.properties.`$session_id`)), 80), 'Int64'), 1000)), NULL)) AS start_timestamp
FROM events_json AS events
@@ -6784,7 +6784,7 @@
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,
- if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS breakdown_value,
+ if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS breakdown_value,
events__session.session_id AS session_id,
min(events__session.`$start_timestamp`) AS start_timestamp
FROM events_json AS events
@@ -6807,13 +6807,13 @@
breakdown_value)
GROUP BY breakdown_value) AS counts
LEFT JOIN
- (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`)))) AS breakdown_value,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))))) AS avg_time_on_page,
quantileIf(0.9)(least(accurateCastOrNull(events.properties.`$prev_pageview_duration`, 'Float64'), 86400),
0) AS previous_avg_time_on_page
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_pathname`), '[]'), '{}'), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(nullIf(toString(events.properties.`$prev_pageview_duration`), '')), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$prev_pageview_duration`), '[]'), '{}'), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
+ WHERE and(equals(events.team_id, 99999), and(or(equals(events.event, '$pageview'), equals(events.event, '$pageleave'), equals(events.event, '$screen')), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_pathname`), '{}'), toJSONString(events.properties.^`$prev_pageview_pathname`), if(isNull(events.properties.`$prev_pageview_pathname`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_pathname`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_pathname`), toString(events.properties.`$prev_pageview_pathname`))))), isNotNull(if(notEquals(toJSONString(events.properties.^`$prev_pageview_duration`), '{}'), toJSONString(events.properties.^`$prev_pageview_duration`), if(isNull(events.properties.`$prev_pageview_duration`), NULL, if(and(in(ascii(toString(events.properties.`$prev_pageview_duration`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$prev_pageview_duration`)), tuple(91, 123))), toJSONString(events.properties.`$prev_pageview_duration`), toString(events.properties.`$prev_pageview_duration`))))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1))
GROUP BY breakdown_value) AS time_on_page ON equals(counts.breakdown_value, time_on_page.breakdown_value)
LEFT JOIN
(SELECT breakdown_value AS breakdown_value,
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_vitals_path_breakdown.new_events_schema.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_vitals_path_breakdown.new_events_schema.ambr
index 3f11c3fd8e4a..12809be352a6 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_vitals_path_breakdown.new_events_schema.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_vitals_path_breakdown.new_events_schema.ambr
@@ -9,7 +9,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -44,7 +44,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -79,7 +79,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -114,7 +114,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_LCP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -149,7 +149,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -184,7 +184,7 @@
path AS path,
value AS value
FROM
- (SELECT replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/<id>') AS path,
+ (SELECT replaceRegexpAll(if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))), '\\/cleaned\\/\\d+', '/cleaned/<id>') AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -219,7 +219,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.9)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -254,7 +254,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.99)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -289,7 +289,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
@@ -324,7 +324,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), ifNull(equals(CAST(events.properties.`$pathname`, 'Nullable(String)'), '/path1'), 0)))
@@ -359,7 +359,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
LEFT OUTER JOIN
@@ -404,7 +404,7 @@
path AS path,
value AS value
FROM
- (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(nullIf(toString(events.properties.`$pathname`), '')), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$pathname`), '[]'), '{}'), toString(events.properties.`$pathname`)))) AS path,
+ (SELECT if(notEquals(toJSONString(events.properties.^`$pathname`), '{}'), toJSONString(events.properties.^`$pathname`), if(isNull(events.properties.`$pathname`), NULL, if(and(in(ascii(toString(events.properties.`$pathname`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$pathname`)), tuple(91, 123))), toJSONString(events.properties.`$pathname`), toString(events.properties.`$pathname`)))) AS path,
quantile(0.75)(accurateCastOrNull(events.properties.`$web_vitals_INP_value`, 'Float64')) AS value
FROM events_json AS events
WHERE and(equals(events.team_id, 99999), and(equals(events.event, '$web_vitals'), isNotNull(path), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-08 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-15 23:59:59', 'UTC')))), 0), 1))
diff --git a/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.new_events_schema.ambr b/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.new_events_schema.ambr
index e3de8fafa73b..1e4a38d1dbae 100644
--- a/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.new_events_schema.ambr
+++ b/products/web_analytics/backend/test/__snapshots__/test_heatmaps_api.new_events_schema.ambr
@@ -9,7 +9,7 @@
WHERE and(equals(heatmaps.team_id, 99999), equals(heatmaps.type, 'click'), greaterOrEquals(heatmaps.timestamp, toDateTime64(toDate('2023-03-08'), 6, 'UTC')), lessOrEquals(heatmaps.timestamp, toDateTime64(plus('2025-03-31', toIntervalDay(1)), 6, 'UTC')), not(and(equals(heatmaps.x, 0), equals(heatmaps.y, 0))), globalIn(heatmaps.session_id,
(SELECT DISTINCT events.properties.`$session_id` AS `$session_id`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '%127.0.0.1%'), 1))))))
+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))), '%127.0.0.1%'), 1))))))
LIMIT 1000000 SETTINGS readonly=2,
max_execution_time=60,
allow_experimental_object_type=1,
@@ -42,7 +42,7 @@
WHERE and(equals(heatmaps.team_id, 99999), equals(heatmaps.type, 'click'), greaterOrEquals(heatmaps.timestamp, toDateTime64(toDate('2023-03-08'), 6, 'UTC')), lessOrEquals(heatmaps.timestamp, toDateTime64(plus('2025-03-31', toIntervalDay(1)), 6, 'UTC')), not(and(equals(heatmaps.x, 0), equals(heatmaps.y, 0))), globalIn(heatmaps.session_id,
(SELECT DISTINCT events.properties.`$session_id` AS `$session_id`
FROM events_json AS events
- WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(nullIf(toString(events.properties.`$host`), '')), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), nullIf(nullIf(toJSONString(events.properties.`$host`), '[]'), '{}'), toString(events.properties.`$host`))))), '%127.0.0.1%'), 1)))))))
+ WHERE and(equals(events.team_id, 99999), notEmpty(events.properties.`$session_id`), and(less(events.timestamp, toDateTime64('today', 6, 'UTC')), greaterOrEquals(events.timestamp, toDateTime64('2023-03-08 00:00:00.000000', 6, 'UTC')), ifNull(notILike(toString(if(notEquals(toJSONString(events.properties.^`$host`), '{}'), toJSONString(events.properties.^`$host`), if(isNull(events.properties.`$host`), NULL, if(and(in(ascii(toString(events.properties.`$host`)), tuple(91, 123)), in(ascii(toJSONString(events.properties.`$host`)), tuple(91, 123))), toJSONString(events.properties.`$host`), toString(events.properties.`$host`))))), '%127.0.0.1%'), 1)))))))
GROUP BY pointer_target_fixed,
pointer_relative_x,
client_y