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.

chore(experiments): delete legacy experiment view tests and stories (#106858)

Anders473fb383b363
diff --git a/common/storybook/storybook-timings.json b/common/storybook/storybook-timings.json
index 33d628a37acc..d151daa2815e 100644
--- a/common/storybook/storybook-timings.json
+++ b/common/storybook/storybook-timings.json
@@ -863,14 +863,6 @@
"chromium": 9.689,
"webkit": 4.325
},
- "frontend/src/scenes/experiments/stories/ExperimentWithLegacyFunnelsQuery.stories.tsx": {
- "chromium": 9.746,
- "webkit": 2.001
- },
- "frontend/src/scenes/experiments/stories/ExperimentWithLegacyTrendsQuery.stories.tsx": {
- "chromium": 10.345,
- "webkit": 2.109
- },
"frontend/src/scenes/experiments/stories/ExperimentWithMeanMetric.stories.tsx": {
"chromium": 8.934,
"webkit": 1.958
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index fb8ea03a00a8..6c611a204e0c 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8836,14 +8836,6 @@ snapshots:
hash: v1.k794b7964.61b7bc8c69675fb3b698a3c84d58d842e66935f311141b859434481e2ed5d484.m41tEjgHnrLNnL7Rvqn4b_aeEY4j0E3iuSaYcTB-bo0
scenes-app-experiments--experiment-with-funnel-metric--light:
hash: v1.k794b7964.2a0b4cdb7cd73cd6d9d498fc8bef89ecea5f3446480af3dd965f30bf1c7c31b1.SlaUlFMuzOUBAhejoICke8deIuko7Nnx_OMsTXiOke0
- scenes-app-experiments--experiment-with-legacy-funnels-query--dark:
- hash: v1.k794b7964.6503cdfd33ae5f9d525d14dc8d43b047e8469beca7e5e489534347904efe1dec.2CtGz-wQvIwr_SQDthwlGJI5bVcJ7bFpetJricY-Lps
- scenes-app-experiments--experiment-with-legacy-funnels-query--light:
- hash: v1.k794b7964.90eb6e86ccabbca83076708acceb7370c5d2981927097a498d952e7c4de46d08.ll4GkGnimLwqqcMyiISsfWian6bSONcAuvzyfXyufgg
- scenes-app-experiments--experiment-with-legacy-trends-query--dark:
- hash: v1.k794b7964.03d4ee126b173c15e89b9c392d324782a429004c648a8bc39b1c38a6d574e108.BdtD3YlFV6RZsqF6JJgwkp0J6TN3JJGL35l47EOwtOU
- scenes-app-experiments--experiment-with-legacy-trends-query--light:
- hash: v1.k794b7964.42c2f3656a5c989d4b1ee34296ca4bb59e186241920a5f8ca21f319069cc6825.6R2u2nPGBnbJYFX2aAn-ZEDtNpa4m1bQA-1aYg8Y7sM
scenes-app-experiments--experiment-with-long-flag-key--dark:
hash: v1.k794b7964.f5a6ab372ff04218344a517d95bac950cfa282cd146b8f2a186043e38006e312.xxUSS05wyUXmz3h8A6HOTZLxKMKIDV2_eazzzRJ5yBA
scenes-app-experiments--experiment-with-long-flag-key--light:
diff --git a/frontend/src/lib/utils/eventUsageLogic.test.ts b/frontend/src/lib/utils/eventUsageLogic.test.ts
index 6e0ce3390372..60c9bdb07047 100644
--- a/frontend/src/lib/utils/eventUsageLogic.test.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.test.ts
@@ -5,11 +5,9 @@ import { SELF_DRIVING_ONBOARDING_EVENT_PROPS } from 'scenes/onboarding/onboardin
import { NodeKind } from '~/queries/schema/schema-general'
import type {
ExperimentFunnelMetric,
- ExperimentFunnelsQuery,
ExperimentMeanMetric,
ExperimentRatioMetric,
ExperimentRetentionMetric,
- ExperimentTrendsQuery,
Node,
} from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -466,42 +464,4 @@ describe('eventUsageLogic', () => {
})
})
})
-
- describe('legacy formats', () => {
- it('extracts ExperimentFunnelsQuery properties', () => {
- const metric = {
- kind: NodeKind.ExperimentFunnelsQuery,
- funnels_query: {
- series: [
- { kind: NodeKind.EventsNode },
- { kind: NodeKind.EventsNode },
- { kind: NodeKind.EventsNode },
- ],
- filterTestAccounts: true,
- },
- } as ExperimentFunnelsQuery
-
- const result = getEventPropertiesForMetric(metric) as Record<string, any>
-
- expect(result.kind).toBe(NodeKind.ExperimentFunnelsQuery)
- expect(result.steps_count).toBe(3)
- expect(result.filter_test_accounts).toBe(true)
- })
-
- it('extracts ExperimentTrendsQuery properties', () => {
- const metric = {
- kind: NodeKind.ExperimentTrendsQuery,
- count_query: {
- series: [{ kind: NodeKind.ActionsNode, id: 1 }],
- filterTestAccounts: false,
- },
- } as ExperimentTrendsQuery
-
- const result = getEventPropertiesForMetric(metric) as Record<string, any>
-
- expect(result.kind).toBe(NodeKind.ExperimentTrendsQuery)
- expect(result.series_kind).toBe(NodeKind.ActionsNode)
- expect(result.filter_test_accounts).toBe(false)
- })
- })
})
diff --git a/frontend/src/mocks/fixtures/api/experiments/_metric_funnel_events.json b/frontend/src/mocks/fixtures/api/experiments/_metric_funnel_events.json
deleted file mode 100644
index 960e555caae3..000000000000
--- a/frontend/src/mocks/fixtures/api/experiments/_metric_funnel_events.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "kind": "ExperimentFunnelsQuery",
- "funnels_query": {
- "kind": "FunnelsQuery",
- "series": [
- {
- "kind": "EventsNode",
- "name": "[jan-16-running] seen",
- "event": "[jan-16-running] seen"
- },
- {
- "kind": "EventsNode",
- "name": "[jan-16-running] payment",
- "event": "[jan-16-running] payment"
- }
- ],
- "dateRange": {
- "date_to": "2025-01-16T23:59",
- "date_from": "2025-01-02T13:54",
- "explicitDate": true
- },
- "funnelsFilter": {
- "layout": "horizontal",
- "funnelVizType": "steps",
- "funnelWindowInterval": 14,
- "funnelWindowIntervalUnit": "day"
- },
- "filterTestAccounts": true
- }
-}
diff --git a/frontend/src/mocks/fixtures/api/experiments/_metric_trend_action.json b/frontend/src/mocks/fixtures/api/experiments/_metric_trend_action.json
deleted file mode 100644
index f8f4a5ef0a1d..000000000000
--- a/frontend/src/mocks/fixtures/api/experiments/_metric_trend_action.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "kind": "ExperimentTrendsQuery",
- "count_query": {
- "kind": "TrendsQuery",
- "series": [
- {
- "kind": "ActionsNode",
- "id": 8,
- "name": "jan-16-running payment action",
- "math": "total"
- }
- ],
- "interval": "day",
- "dateRange": {
- "date_to": "2025-01-16T23:59",
- "date_from": "2025-01-02T13:54",
- "explicitDate": true
- },
- "trendsFilter": {
- "display": "ActionsLineGraph"
- },
- "filterTestAccounts": true
- }
-}
diff --git a/frontend/src/mocks/fixtures/api/experiments/_metric_trend_custom_exposure.json b/frontend/src/mocks/fixtures/api/experiments/_metric_trend_custom_exposure.json
deleted file mode 100644
index 44ba5736371a..000000000000
--- a/frontend/src/mocks/fixtures/api/experiments/_metric_trend_custom_exposure.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "kind": "ExperimentTrendsQuery",
- "count_query": {
- "kind": "TrendsQuery",
- "series": [
- {
- "kind": "EventsNode",
- "math": "total",
- "name": "[jan-16-running] event one",
- "event": "[jan-16-running] event one"
- }
- ],
- "interval": "day",
- "dateRange": {
- "date_to": "2025-01-16T23:59",
- "date_from": "2025-01-02T13:54",
- "explicitDate": true
- },
- "trendsFilter": {
- "display": "ActionsLineGraph"
- },
- "filterTestAccounts": true
- },
- "exposure_query": {
- "kind": "TrendsQuery",
- "series": [
- {
- "kind": "EventsNode",
- "math": "dau",
- "name": "[jan-16-running] event zero",
- "event": "[jan-16-running] event zero"
- }
- ],
- "interval": "day",
- "dateRange": {
- "date_to": "2025-01-23T23:59",
- "date_from": "2025-01-09T15:10",
- "explicitDate": true
- },
- "trendsFilter": {
- "display": "ActionsLineGraph"
- },
- "filterTestAccounts": true
- }
-}
diff --git a/frontend/src/mocks/fixtures/api/experiments/_metric_trend_feature_flag_called.json b/frontend/src/mocks/fixtures/api/experiments/_metric_trend_feature_flag_called.json
deleted file mode 100644
index a1fd2c3fc874..000000000000
--- a/frontend/src/mocks/fixtures/api/experiments/_metric_trend_feature_flag_called.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "kind": "ExperimentTrendsQuery",
- "count_query": {
- "kind": "TrendsQuery",
- "series": [
- {
- "kind": "EventsNode",
- "math": "total",
- "name": "[jan-16-running] event one",
- "event": "[jan-16-running] event one"
- }
- ],
- "interval": "day",
- "dateRange": {
- "date_to": "2025-01-16T23:59",
- "date_from": "2025-01-02T13:54",
- "explicitDate": true
- },
- "trendsFilter": {
- "display": "ActionsLineGraph"
- },
- "filterTestAccounts": true
- }
-}
diff --git a/frontend/src/mocks/fixtures/api/experiments/funnels_query_result.json b/frontend/src/mocks/fixtures/api/experiments/funnels_query_result.json
deleted file mode 100644
index 1d297f58f6f3..000000000000
--- a/frontend/src/mocks/fixtures/api/experiments/funnels_query_result.json
+++ /dev/null
@@ -1,208 +0,0 @@
-{
- "cache_key": "cache_d595959a405bf8002f791577a6806453",
- "cache_target_age": "2025-06-04T14:20:11.819746Z",
- "calculation_trigger": null,
- "credible_intervals": {
- "control": [0.10385703759823513, 0.14632977457890145],
- "test-1": [0.15399819805182086, 0.20513822790568542],
- "test-2": [0.21266251721549914, 0.26028822153768866]
- },
- "expected_loss": 0.00010051784352294164,
- "funnels_query": {
- "aggregation_group_type_index": null,
- "breakdownFilter": {
- "breakdown": "$feature/experiment-funnels-query",
- "breakdown_group_type_index": null,
- "breakdown_hide_other_aggregation": null,
- "breakdown_histogram_bin_count": null,
- "breakdown_limit": null,
- "breakdown_normalize_url": null,
- "breakdown_type": "event",
- "breakdowns": null
- },
- "dataColorTheme": null,
- "dateRange": {
- "date_from": "2025-05-20T14:16:00+00:00",
- "date_to": null,
- "explicitDate": true
- },
- "filterTestAccounts": true,
- "funnelsFilter": {
- "binCount": null,
- "breakdownAttributionType": "first_touch",
- "breakdownAttributionValue": null,
- "exclusions": [],
- "funnelAggregateByHogQL": null,
- "funnelFromStep": null,
- "funnelOrderType": "ordered",
- "funnelStepReference": "total",
- "funnelToStep": null,
- "funnelVizType": "steps",
- "funnelWindowInterval": 14,
- "funnelWindowIntervalUnit": "day",
- "hiddenLegendBreakdowns": null,
- "layout": "vertical",
- "resultCustomizations": null,
- "useUdf": null
- },
- "interval": null,
- "kind": "FunnelsQuery",
- "modifiers": null,
- "properties": [],
- "response": null,
- "samplingFactor": null,
- "series": [
- {
- "custom_name": null,
- "event": "signup started",
- "fixedProperties": null,
- "kind": "EventsNode",
- "limit": null,
- "math": null,
- "math_group_type_index": null,
- "math_hogql": null,
- "math_property": null,
- "math_property_revenue_currency": null,
- "math_property_type": null,
- "name": "signup started",
- "orderBy": null,
- "properties": null,
- "response": null
- },
- {
- "custom_name": null,
- "event": "signup completed",
- "fixedProperties": null,
- "kind": "EventsNode",
- "limit": null,
- "math": null,
- "math_group_type_index": null,
- "math_hogql": null,
- "math_property": null,
- "math_property_revenue_currency": null,
- "math_property_type": null,
- "name": "signup completed",
- "orderBy": null,
- "properties": null,
- "response": null
- }
- ]
- },
- "insight": [
- [
- {
- "action_id": "signup started",
- "name": "signup started",
- "custom_name": null,
- "order": 0,
- "people": [],
- "count": 859,
- "type": "events",
- "average_conversion_time": null,
- "median_conversion_time": null,
- "breakdown": ["test-1"],
- "breakdown_value": ["test-1"]
- },
- {
- "action_id": "signup completed",
- "name": "signup completed",
- "custom_name": null,
- "order": 1,
- "people": [],
- "count": 153,
- "type": "events",
- "average_conversion_time": 0.0,
- "median_conversion_time": 0.0,
- "breakdown": ["test-1"],
- "breakdown_value": ["test-1"]
- }
- ],
- [
- {
- "action_id": "signup started",
- "name": "signup started",
- "custom_name": null,
- "order": 0,
- "people": [],
- "count": 1218,
- "type": "events",
- "average_conversion_time": null,
- "median_conversion_time": null,
- "breakdown": ["test-2"],
- "breakdown_value": ["test-2"]
- },
- {
- "action_id": "signup completed",
- "name": "signup completed",
- "custom_name": null,
- "order": 1,
- "people": [],
- "count": 287,
- "type": "events",
- "average_conversion_time": 0.0,
- "median_conversion_time": 0.0,
- "breakdown": ["test-2"],
- "breakdown_value": ["test-2"]
- }
- ],
- [
- {
- "action_id": "signup started",
- "name": "signup started",
- "custom_name": null,
- "order": 0,
- "people": [],
- "count": 923,
- "type": "events",
- "average_conversion_time": null,
- "median_conversion_time": null,
- "breakdown": ["control"],
- "breakdown_value": ["control"]
- },
- {
- "action_id": "signup completed",
- "name": "signup completed",
- "custom_name": null,
- "order": 1,
- "people": [],
- "count": 114,
- "type": "events",
- "average_conversion_time": 0.0,
- "median_conversion_time": 0.0,
- "breakdown": ["control"],
- "breakdown_value": ["control"]
- }
- ]
- ],
- "is_cached": true,
- "kind": "ExperimentFunnelsQuery",
- "last_refresh": "2025-06-03T14:20:11.819746Z",
- "next_allowed_client_refresh": "2025-06-03T14:21:11.819746Z",
- "probability": {
- "control": 0.0,
- "test-1": 0.9996,
- "test-2": 1.0
- },
- "query_status": null,
- "significance_code": "significant",
- "significant": true,
- "stats_version": 2,
- "timezone": "UTC",
- "variants": [
- {
- "failure_count": 809.0,
- "key": "control",
- "success_count": 114.0
- },
- {
- "failure_count": 706.0,
- "key": "test-1",
- "success_count": 153.0
- },
- {
- "failure_count": 931.0,
- "key": "test-2",
- "success_count": 287.0
- }
- ]
-}
diff --git a/frontend/src/mocks/fixtures/api/experiments/trends_query_result.json b/frontend/src/mocks/fixtures/api/experiments/trends_query_result.json
deleted file mode 100644
index 6f2c74ff7123..000000000000
--- a/frontend/src/mocks/fixtures/api/experiments/trends_query_result.json
+++ /dev/null
@@ -1,506 +0,0 @@
-{
- "cache_key": "cache_207e9fcf39db7c83a4c604f674f011aa",
- "cache_target_age": "2025-06-04T14:01:24.201213Z",
- "calculation_trigger": null,
- "count_query": {
- "aggregation_group_type_index": null,
- "breakdownFilter": {
- "breakdown": "$feature/experiment-trends-query",
- "breakdown_group_type_index": null,
- "breakdown_hide_other_aggregation": null,
- "breakdown_histogram_bin_count": null,
- "breakdown_limit": null,
- "breakdown_normalize_url": null,
- "breakdown_type": "event",
- "breakdowns": null
- },
- "compareFilter": null,
- "conversionGoal": null,
- "dataColorTheme": null,
- "dateRange": {
- "date_from": "2025-05-20T14:01:00+00:00",
- "date_to": null,
- "explicitDate": true
- },
- "filterTestAccounts": true,
- "interval": "day",
- "kind": "TrendsQuery",
- "modifiers": null,
- "properties": [
- {
- "key": "$feature/experiment-trends-query",
- "label": null,
- "operator": "exact",
- "type": "event",
- "value": ["control", "test-1", "test-2"]
- }
- ],
- "response": null,
- "samplingFactor": null,
- "series": [
- {
- "custom_name": null,
- "event": "$pageview",
- "fixedProperties": null,
- "kind": "EventsNode",
- "limit": null,
- "math": null,
- "math_group_type_index": null,
- "math_hogql": null,
- "math_property": null,
- "math_property_revenue_currency": null,
- "math_property_type": null,
- "name": "$pageview",
- "orderBy": null,
- "properties": null,
- "response": null
- }
- ],
- "trendsFilter": {
- "aggregationAxisFormat": "numeric",
- "aggregationAxisPostfix": null,
- "aggregationAxisPrefix": null,
- "breakdown_histogram_bin_count": null,
- "decimalPlaces": null,
- "display": "ActionsLineGraphCumulative",
- "formula": null,
- "formulaNodes": null,
- "formulas": null,
- "goalLines": null,
- "hiddenLegendIndexes": null,
- "minDecimalPlaces": null,
- "resultCustomizationBy": "value",
- "resultCustomizations": null,
- "showAlertThresholdLines": false,
- "showLabelsOnSeries": null,
- "showLegend": false,
- "showMultipleYAxes": false,
- "showPercentStackView": false,
- "showValuesOnSeries": false,
- "smoothingIntervals": 1,
- "yAxisScaleType": "linear"
- }
- },
- "credible_intervals": {
- "control": [1.1067233758884238, 1.3907190022877942],
- "test-2": [1.640404242512753, 1.953524709273948],
- "test-1": [1.699699479925885, 2.050918516814496]
- },
- "exposure_query": {
- "aggregation_group_type_index": null,
- "breakdownFilter": {
- "breakdown": "$feature_flag_response",
- "breakdown_group_type_index": null,
- "breakdown_hide_other_aggregation": null,
- "breakdown_histogram_bin_count": null,
- "breakdown_limit": null,
- "breakdown_normalize_url": null,
- "breakdown_type": "event",
- "breakdowns": null
- },
- "compareFilter": null,
- "conversionGoal": null,
- "dataColorTheme": null,
- "dateRange": {
- "date_from": "2025-05-20T14:01:00+00:00",
- "date_to": null,
- "explicitDate": true
- },
- "filterTestAccounts": true,
- "interval": "day",
- "kind": "TrendsQuery",
- "modifiers": null,
- "properties": [
- {
- "key": "$feature_flag_response",
- "label": null,
- "operator": "exact",
- "type": "event",
- "value": ["control", "test-1", "test-2"]
- },
- {
- "key": "$feature_flag",
- "label": null,
- "operator": "exact",
- "type": "event",
- "value": ["experiment-trends-query"]
- }
- ],
- "response": null,
- "samplingFactor": null,
- "series": [
- {
- "custom_name": null,
- "event": "$feature_flag_called",
- "fixedProperties": null,
- "kind": "EventsNode",
- "limit": null,
- "math": "dau",
- "math_group_type_index": null,
- "math_hogql": null,
- "math_property": null,
- "math_property_revenue_currency": null,
- "math_property_type": null,
- "name": null,
- "orderBy": null,
- "properties": null,
- "response": null
- }
- ],
- "trendsFilter": {
- "aggregationAxisFormat": "numeric",
- "aggregationAxisPostfix": null,
- "aggregationAxisPrefix": null,
- "breakdown_histogram_bin_count": null,
- "decimalPlaces": null,
- "display": "ActionsLineGraphCumulative",
- "formula": null,
- "formulaNodes": null,
- "formulas": null,
- "goalLines": null,
- "hiddenLegendIndexes": null,
- "minDecimalPlaces": null,
- "resultCustomizationBy": "value",
- "resultCustomizations": null,
- "showAlertThresholdLines": false,
- "showLabelsOnSeries": null,
- "showLegend": false,
- "showMultipleYAxes": false,
- "showPercentStackView": false,
- "showValuesOnSeries": false,
- "smoothingIntervals": 1,
- "yAxisScaleType": "linear"
- }
- },
- "insight": [
- {
- "data": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 36.0, 132.0, 226.0, 277.0, 346.0, 415.0, 482.0, 503.0],
- "labels": [
- "20-May-2025",
- "21-May-2025",
- "22-May-2025",
- "23-May-2025",
- "24-May-2025",
- "25-May-2025",
- "26-May-2025",
- "27-May-2025",
- "28-May-2025",
- "29-May-2025",
- "30-May-2025",
- "31-May-2025",
- "1-Jun-2025",
- "2-Jun-2025",
- "3-Jun-2025"
- ],
- "days": [
- "2025-05-20",
- "2025-05-21",
- "2025-05-22",
- "2025-05-23",
- "2025-05-24",
- "2025-05-25",
- "2025-05-26",
- "2025-05-27",
- "2025-05-28",
- "2025-05-29",
- "2025-05-30",
- "2025-05-31",
- "2025-06-01",
- "2025-06-02",
- "2025-06-03"
- ],
- "count": 503.0,
- "label": "test-2",
- "filter": {
- "insight": "TRENDS",
- "properties": [
- {
- "key": "$feature/experiment-trends-query",
- "label": null,
- "operator": "exact",
- "type": "event",
- "value": ["control", "test-1", "test-2"]
- }
- ],
- "filter_test_accounts": true,
- "date_to": "2025-06-03T14:01:24.769086Z",
- "date_from": "2025-05-20T14:01:00Z",
- "entity_type": "events",
- "interval": "day",
- "aggregationAxisFormat": "numeric",
- "display": "ActionsLineGraphCumulative",
- "resultCustomizationBy": "value",
- "showAlertThresholdLines": false,
- "showLegend": false,
- "showMultipleYAxes": false,
- "showPercentStackView": false,
- "showValuesOnSeries": false,
- "smoothingIntervals": 1,
- "yAxisScaleType": "linear",
- "breakdown": "$feature/experiment-trends-query",
- "breakdown_type": "event"
- },
- "action": {
- "days": [
- "2025-05-20T00:00:00Z",
- "2025-05-21T00:00:00Z",
- "2025-05-22T00:00:00Z",
- "2025-05-23T00:00:00Z",
- "2025-05-24T00:00:00Z",
- "2025-05-25T00:00:00Z",
- "2025-05-26T00:00:00Z",
- "2025-05-27T00:00:00Z",
- "2025-05-28T00:00:00Z",
- "2025-05-29T00:00:00Z",
- "2025-05-30T00:00:00Z",
- "2025-05-31T00:00:00Z",
- "2025-06-01T00:00:00Z",
- "2025-06-02T00:00:00Z",
- "2025-06-03T00:00:00Z"
- ],
- "id": "$pageview",
- "type": "events",
- "order": 0,
- "name": "$pageview",
- "custom_name": null,
- "math": null,
- "math_property": null,
- "math_hogql": null,
- "math_group_type_index": null,
- "properties": {}
- },
- "breakdown_value": "test-2"
- },
- {
- "data": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 23.0, 80.0, 119.0, 211.0, 270.0, 340.0, 399.0, 435.0],
- "labels": [
- "20-May-2025",
- "21-May-2025",
- "22-May-2025",
- "23-May-2025",
- "24-May-2025",
- "25-May-2025",
- "26-May-2025",
- "27-May-2025",
- "28-May-2025",
- "29-May-2025",
- "30-May-2025",
- "31-May-2025",
- "1-Jun-2025",
- "2-Jun-2025",
- "3-Jun-2025"
- ],
- "days": [
- "2025-05-20",
- "2025-05-21",
- "2025-05-22",
- "2025-05-23",
- "2025-05-24",
- "2025-05-25",
- "2025-05-26",
- "2025-05-27",
- "2025-05-28",
- "2025-05-29",
- "2025-05-30",
- "2025-05-31",
- "2025-06-01",
- "2025-06-02",
- "2025-06-03"
- ],
- "count": 435.0,
- "label": "test-1",
- "filter": {
- "insight": "TRENDS",
- "properties": [
- {
- "key": "$feature/experiment-trends-query",
- "label": null,
- "operator": "exact",
- "type": "event",
- "value": ["control", "test-1", "test-2"]
- }
- ],
- "filter_test_accounts": true,
- "date_to": "2025-06-03T14:01:24.769086Z",
- "date_from": "2025-05-20T14:01:00Z",
- "entity_type": "events",
- "interval": "day",
- "aggregationAxisFormat": "numeric",
- "display": "ActionsLineGraphCumulative",
- "resultCustomizationBy": "value",
- "showAlertThresholdLines": false,
- "showLegend": false,
- "showMultipleYAxes": false,
- "showPercentStackView": false,
- "showValuesOnSeries": false,
- "smoothingIntervals": 1,
- "yAxisScaleType": "linear",
- "breakdown": "$feature/experiment-trends-query",
- "breakdown_type": "event"
- },
- "action": {
- "days": [
- "2025-05-20T00:00:00Z",
- "2025-05-21T00:00:00Z",
- "2025-05-22T00:00:00Z",
- "2025-05-23T00:00:00Z",
- "2025-05-24T00:00:00Z",
- "2025-05-25T00:00:00Z",
- "2025-05-26T00:00:00Z",
- "2025-05-27T00:00:00Z",
- "2025-05-28T00:00:00Z",
- "2025-05-29T00:00:00Z",
- "2025-05-30T00:00:00Z",
- "2025-05-31T00:00:00Z",
- "2025-06-01T00:00:00Z",
- "2025-06-02T00:00:00Z",
- "2025-06-03T00:00:00Z"
- ],
- "id": "$pageview",
- "type": "events",
- "order": 0,
- "name": "$pageview",
- "custom_name": null,
- "math": null,
- "math_property": null,
- "math_hogql": null,
- "math_group_type_index": null,
- "properties": {}
- },
- "breakdown_value": "test-1"
- },
- {
- "data": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 21.0, 62.0, 101.0, 142.0, 177.0, 210.0, 270.0, 294.0],
- "labels": [
- "20-May-2025",
- "21-May-2025",
- "22-May-2025",
- "23-May-2025",
- "24-May-2025",
- "25-May-2025",
- "26-May-2025",
- "27-May-2025",
- "28-May-2025",
- "29-May-2025",
- "30-May-2025",
- "31-May-2025",
- "1-Jun-2025",
- "2-Jun-2025",
- "3-Jun-2025"
- ],
- "days": [
- "2025-05-20",
- "2025-05-21",
- "2025-05-22",
- "2025-05-23",
- "2025-05-24",
- "2025-05-25",
- "2025-05-26",
- "2025-05-27",
- "2025-05-28",
- "2025-05-29",
- "2025-05-30",
- "2025-05-31",
- "2025-06-01",
- "2025-06-02",
- "2025-06-03"
- ],
- "count": 294.0,
- "label": "control",
- "filter": {
- "insight": "TRENDS",
- "properties": [
- {
- "key": "$feature/experiment-trends-query",
- "label": null,
- "operator": "exact",
- "type": "event",
- "value": ["control", "test-1", "test-2"]
- }
- ],
- "filter_test_accounts": true,
- "date_to": "2025-06-03T14:01:24.769086Z",
- "date_from": "2025-05-20T14:01:00Z",
- "entity_type": "events",
- "interval": "day",
- "aggregationAxisFormat": "numeric",
- "display": "ActionsLineGraphCumulative",
- "resultCustomizationBy": "value",
- "showAlertThresholdLines": false,
- "showLegend": false,
- "showMultipleYAxes": false,
- "showPercentStackView": false,
- "showValuesOnSeries": false,
- "smoothingIntervals": 1,
- "yAxisScaleType": "linear",
- "breakdown": "$feature/experiment-trends-query",
- "breakdown_type": "event"
- },
- "action": {
- "days": [
- "2025-05-20T00:00:00Z",
- "2025-05-21T00:00:00Z",
- "2025-05-22T00:00:00Z",
- "2025-05-23T00:00:00Z",
- "2025-05-24T00:00:00Z",
- "2025-05-25T00:00:00Z",
- "2025-05-26T00:00:00Z",
- "2025-05-27T00:00:00Z",
- "2025-05-28T00:00:00Z",
- "2025-05-29T00:00:00Z",
- "2025-05-30T00:00:00Z",
- "2025-05-31T00:00:00Z",
- "2025-06-01T00:00:00Z",
- "2025-06-02T00:00:00Z",
- "2025-06-03T00:00:00Z"
- ],
- "id": "$pageview",
- "type": "events",
- "order": 0,
- "name": "$pageview",
- "custom_name": null,
- "math": null,
- "math_property": null,
- "math_hogql": null,
- "math_group_type_index": null,
- "properties": {}
- },
- "breakdown_value": "control"
- }
- ],
- "is_cached": true,
- "kind": "ExperimentTrendsQuery",
- "last_refresh": "2025-06-03T14:01:24.201213Z",
- "next_allowed_client_refresh": "2025-06-03T14:02:24.201213Z",
- "p_value": 0.01892128132882989,
- "probability": {
- "control": 0.0,
- "test-2": 1.0,
- "test-1": 1.0
- },
- "query_status": null,
- "significance_code": "high_loss",
- "significant": false,
- "stats_version": 2,
- "timezone": "UTC",
- "variants": [
- {
- "absolute_exposure": 236.0,
- "count": 294.0,
- "exposure": 1.0,
- "key": "control"
- },
- {
- "absolute_exposure": 280.0,
- "count": 503.0,
- "exposure": 1.1864406779661016,
- "key": "test-2"
- },
- {
- "absolute_exposure": 232.0,
- "count": 435.0,
- "exposure": 0.9830508474576272,
- "key": "test-1"
- }
- ]
-}
diff --git a/frontend/src/scenes/experiments/stories/ExperimentWithLegacyFunnelsQuery.stories.tsx b/frontend/src/scenes/experiments/stories/ExperimentWithLegacyFunnelsQuery.stories.tsx
deleted file mode 100644
index 28be378a5f2e..000000000000
--- a/frontend/src/scenes/experiments/stories/ExperimentWithLegacyFunnelsQuery.stories.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Meta, StoryObj } from '@storybook/react'
-
-import { makeDelay } from 'lib/utils/async'
-import { App } from 'scenes/App'
-import { urls } from 'scenes/urls'
-
-import { mswDecorator } from '~/mocks/browser'
-import EXPERIMENT_WITH_FUNNELS_QUERY from '~/mocks/fixtures/api/experiments/experiment_with_funnels_query.json'
-import EXPOSURE_QUERY_RESULT from '~/mocks/fixtures/api/experiments/exposure_query_result.json'
-import FUNNELS_QUERY_RESULT from '~/mocks/fixtures/api/experiments/funnels_query_result.json'
-import { NodeKind } from '~/queries/schema/schema-general'
-
-const meta: Meta = {
- component: App,
- title: 'Scenes-App/Experiments',
- parameters: {
- layout: 'fullscreen',
- viewMode: 'story',
- mockDate: '2025-01-27',
- pageUrl: urls.experiment(EXPERIMENT_WITH_FUNNELS_QUERY.id),
- },
- decorators: [
- mswDecorator({
- get: {
- [`/api/projects/:team_id/experiments/${EXPERIMENT_WITH_FUNNELS_QUERY.id}/`]:
- EXPERIMENT_WITH_FUNNELS_QUERY,
- [`/api/projects/:team_id/experiment_holdouts`]: [],
- [`/api/projects/:team_id/experiment_saved_metrics/`]: [],
- [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_FUNNELS_QUERY.feature_flag.id}/`]: {},
- [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_FUNNELS_QUERY.feature_flag.id}/status/`]: {},
- [`/api/environments/:team_id/default_release_conditions/`]: [],
- },
- post: {
- '/api/environments/:team_id/query/:kind': async ({ request }) => {
- const body = (await request.json()) as Record<string, any>
-
- if (body.query.kind === NodeKind.ExperimentExposureQuery) {
- return [200, EXPOSURE_QUERY_RESULT]
- }
-
- return [200, FUNNELS_QUERY_RESULT]
- },
- },
- }),
- ],
-}
-export default meta
-
-type Story = StoryObj<{}>
-
-// Small delay to ensure charts render completely
-export const ExperimentWithLegacyFunnelsQuery: Story = { play: makeDelay(500) }
diff --git a/frontend/src/scenes/experiments/stories/ExperimentWithLegacyTrendsQuery.stories.tsx b/frontend/src/scenes/experiments/stories/ExperimentWithLegacyTrendsQuery.stories.tsx
deleted file mode 100644
index 13f0b7433055..000000000000
--- a/frontend/src/scenes/experiments/stories/ExperimentWithLegacyTrendsQuery.stories.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Meta, StoryObj } from '@storybook/react'
-
-import { makeDelay } from 'lib/utils/async'
-import { App } from 'scenes/App'
-import { urls } from 'scenes/urls'
-
-import { mswDecorator } from '~/mocks/browser'
-import EXPERIMENT_WITH_TRENDS_QUERY from '~/mocks/fixtures/api/experiments/experiment_with_trends_query.json'
-import EXPOSURE_QUERY_RESULT from '~/mocks/fixtures/api/experiments/exposure_query_result.json'
-import TRENDS_QUERY_RESULT from '~/mocks/fixtures/api/experiments/trends_query_result.json'
-import { NodeKind } from '~/queries/schema/schema-general'
-
-const meta: Meta = {
- component: App,
- title: 'Scenes-App/Experiments',
- parameters: {
- layout: 'fullscreen',
- viewMode: 'story',
- mockDate: '2025-01-27',
- pageUrl: urls.experiment(EXPERIMENT_WITH_TRENDS_QUERY.id),
- },
- decorators: [
- mswDecorator({
- get: {
- [`/api/projects/:team_id/experiments/${EXPERIMENT_WITH_TRENDS_QUERY.id}/`]:
- EXPERIMENT_WITH_TRENDS_QUERY,
- [`/api/projects/:team_id/experiment_holdouts`]: [],
- [`/api/projects/:team_id/experiment_saved_metrics/`]: [],
- [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_TRENDS_QUERY.feature_flag.id}/`]: {},
- [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_TRENDS_QUERY.feature_flag.id}/status/`]: {},
- [`/api/environments/:team_id/default_release_conditions/`]: [],
- },
- post: {
- '/api/environments/:team_id/query/:kind': async ({ request }) => {
- const body = (await request.json()) as Record<string, any>
-
- if (body.query.kind === NodeKind.ExperimentExposureQuery) {
- return [200, EXPOSURE_QUERY_RESULT]
- }
-
- return [200, TRENDS_QUERY_RESULT]
- },
- },
- }),
- ],
-}
-export default meta
-
-type Story = StoryObj<{}>
-
-// Small delay to ensure charts render completely
-export const ExperimentWithLegacyTrendsQuery: Story = { play: makeDelay(500) }
diff --git a/frontend/src/scenes/experiments/utils.test.ts b/frontend/src/scenes/experiments/utils.test.ts
index 29ae34206f2e..b3c154c0905b 100644
--- a/frontend/src/scenes/experiments/utils.test.ts
+++ b/frontend/src/scenes/experiments/utils.test.ts
@@ -1,17 +1,10 @@
import experimentJson from '~/mocks/fixtures/api/experiments/_experiment_launched_with_funnel_and_trends.json'
-import metricFunnelEventsJson from '~/mocks/fixtures/api/experiments/_metric_funnel_events.json'
-import metricTrendActionJson from '~/mocks/fixtures/api/experiments/_metric_trend_action.json'
-import metricTrendCustomExposureJson from '~/mocks/fixtures/api/experiments/_metric_trend_custom_exposure.json'
-import metricTrendFeatureFlagCalledJson from '~/mocks/fixtures/api/experiments/_metric_trend_feature_flag_called.json'
-import EXPERIMENT_WITH_MEAN_METRIC from '~/mocks/fixtures/api/experiments/experiment_with_mean_metric.json'
import {
Breakdown,
CachedNewExperimentQueryResponse,
ExperimentEventExposureConfig,
- ExperimentFunnelsQuery,
ExperimentMetric,
ExperimentMetricType,
- ExperimentTrendsQuery,
NodeKind,
ProductKey,
} from '~/queries/schema/schema-general'
@@ -40,7 +33,6 @@ import {
getFunnelDropoffReason,
getOrderedMetricsWithResults,
getSessionLinkabilityEventNames,
- getViewRecordingFiltersLegacy,
isEvenlyDistributed,
isLegacyExperiment,
isLegacyExperimentQuery,
@@ -273,178 +265,6 @@ describe('getFunnelDropoffReason', () => {
})
})
-describe('getViewRecordingFiltersLegacy', () => {
- const featureFlagKey = 'jan-16-running'
-
- it('returns the correct filters for an experiment query', () => {
- const filters = getViewRecordingFiltersLegacy(
- EXPERIMENT_WITH_MEAN_METRIC.metrics[0] as ExperimentMetric,
- featureFlagKey,
- 'control'
- )
- expect(filters).toEqual([
- {
- id: '$pageview',
- name: '$pageview',
- type: 'events',
- properties: [
- {
- key: `$feature/${featureFlagKey}`,
- type: PropertyFilterType.Event,
- value: ['control'],
- operator: PropertyOperator.Exact,
- },
- ],
- },
- ])
- })
-
- it('returns the correct filters for a funnel metric', () => {
- const filters = getViewRecordingFiltersLegacy(
- metricFunnelEventsJson as ExperimentFunnelsQuery,
- featureFlagKey,
- 'control'
- )
- expect(filters).toEqual([
- {
- id: '[jan-16-running] seen',
- name: '[jan-16-running] seen',
- type: 'events',
- properties: [
- {
- key: `$feature/${featureFlagKey}`,
- type: PropertyFilterType.Event,
- value: ['control'],
- operator: PropertyOperator.Exact,
- },
- ],
- },
- {
- id: '[jan-16-running] payment',
- name: '[jan-16-running] payment',
- type: 'events',
- properties: [
- {
- key: `$feature/${featureFlagKey}`,
- type: PropertyFilterType.Event,
- value: ['control'],
- operator: PropertyOperator.Exact,
- },
- ],
- },
- ])
- })
- it('returns the correct filters for a trend metric', () => {
- const filters = getViewRecordingFiltersLegacy(
- metricTrendFeatureFlagCalledJson as ExperimentTrendsQuery,
- featureFlagKey,
- 'test'
- )
- expect(filters).toEqual([
- {
- id: '$feature_flag_called',
- name: '$feature_flag_called',
- type: 'events',
- properties: [
- {
- key: '$feature_flag_response',
- type: PropertyFilterType.Event,
- value: ['test'],
- operator: PropertyOperator.Exact,
- },
- {
- key: '$feature_flag',
- type: PropertyFilterType.Event,
- value: 'jan-16-running',
- operator: PropertyOperator.Exact,
- },
- ],
- },
- {
- id: '[jan-16-running] event one',
- name: '[jan-16-running] event one',
- type: 'events',
- properties: [
- {
- key: `$feature/${featureFlagKey}`,
- type: PropertyFilterType.Event,
- value: ['test'],
- operator: PropertyOperator.Exact,
- },
- ],
- },
- ])
- })
- it('returns the correct filters for a trend metric with custom exposure', () => {
- const filters = getViewRecordingFiltersLegacy(
- metricTrendCustomExposureJson as ExperimentTrendsQuery,
- featureFlagKey,
- 'test'
- )
- expect(filters).toEqual([
- {
- id: '[jan-16-running] event zero',
- name: '[jan-16-running] event zero',
- type: 'events',
- properties: [
- {
- key: `$feature/${featureFlagKey}`,
- type: PropertyFilterType.Event,
- value: ['test'],
- operator: PropertyOperator.Exact,
- },
- ],
- },
- {
- id: '[jan-16-running] event one',
- name: '[jan-16-running] event one',
- type: 'events',
- properties: [
- {
- key: `$feature/${featureFlagKey}`,
- type: PropertyFilterType.Event,
- value: ['test'],
- operator: PropertyOperator.Exact,
- },
- ],
- },
- ])
- })
- it('returns the correct filters for a trend metric with an action', () => {
- const filters = getViewRecordingFiltersLegacy(
- metricTrendActionJson as ExperimentTrendsQuery,
- featureFlagKey,
- 'test'
- )
- expect(filters).toEqual([
- {
- id: '$feature_flag_called',
- name: '$feature_flag_called',
- type: 'events',
- properties: [
- {
- key: '$feature_flag_response',
- type: PropertyFilterType.Event,
- value: ['test'],
- operator: PropertyOperator.Exact,
- },
- {
- key: '$feature_flag',
- type: PropertyFilterType.Event,
- value: 'jan-16-running',
- operator: PropertyOperator.Exact,
- },
- ],
- },
- {
- id: 8,
- name: 'jan-16-running payment action',
- type: 'actions',
- },
- ])
- })
-})
-
describe('checkFeatureFlagEligibility', () => {
const baseFeatureFlag: FeatureFlagType = {
id: 1,
diff --git a/posthog/api/test/test_utils.py b/posthog/api/test/test_utils.py
index 3b72fd7f397d..f425b354aa0f 100644
--- a/posthog/api/test/test_utils.py
+++ b/posthog/api/test/test_utils.py
@@ -287,18 +287,6 @@ class TestUtils(BaseTest):
("HogQLQuery is insight", {"kind": "HogQLQuery"}, True, True),
("TracesQuery gets extended timeout only", {"kind": "TracesQuery"}, False, True),
("ExperimentQuery gets extended timeout only", {"kind": "ExperimentQuery"}, False, True),
- (
- "ExperimentTrendsQuery gets extended timeout only",
- {"kind": "ExperimentTrendsQuery"},
- False,
- True,
- ),
- (
- "ExperimentFunnelsQuery gets extended timeout only",
- {"kind": "ExperimentFunnelsQuery"},
- False,
- True,
- ),
(
"ExperimentExposureQuery gets extended timeout only",
{"kind": "ExperimentExposureQuery"},
diff --git a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambr b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambr
deleted file mode 100644
index 531ba485b131..000000000000
--- a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambr
+++ /dev/null
@@ -1,703 +0,0 @@
-# serializer version: 1
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_0_person_id_override_properties_on_events_no_filter
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_0_person_id_override_properties_on_events_no_filter.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- 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', 'purchase')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@posthog.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_1_person_id_override_properties_on_events_filter_earlierevent
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_1_person_id_override_properties_on_events_filter_earlierevent.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- 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', 'purchase')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@earlierevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_2_person_id_override_properties_on_events_filter_laterevent
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_2_person_id_override_properties_on_events_filter_laterevent.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- 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', 'purchase')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@laterevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_3_person_id_override_properties_joined_no_filter
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_3_person_id_override_properties_joined_no_filter.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(e__person.properties___email), '%@posthog.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_4_person_id_override_properties_joined_filter_earlierevent
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_4_person_id_override_properties_joined_filter_earlierevent.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(e__person.properties___email), '%@earlierevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_5_person_id_override_properties_joined_filter_laterevent
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_5_person_id_override_properties_joined_filter_laterevent.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(e__person.properties___email), '%@laterevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_6_person_id_no_override_properties_on_events_no_filter
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_6_person_id_no_override_properties_on_events_no_filter.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- e.person_id AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-31 00:00:00.000000', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@posthog.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_7_person_id_no_override_properties_on_events_filter_earlierevent
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_7_person_id_no_override_properties_on_events_filter_earlierevent.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- e.person_id AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-31 00:00:00.000000', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@earlierevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_8_person_id_no_override_properties_on_events_filter_laterevent
- '''
-
- SELECT DISTINCT person_id
- FROM events
- WHERE team_id = 99999
- AND distinct_id = 'person_id_1_distinct_id_2'
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_8_person_id_no_override_properties_on_events_filter_laterevent.1
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- e.person_id AS aggregation_target,
- e.uuid AS uuid,
- e.`$session_id` AS `$session_id`,
- e.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), '')] AS prop_basic,
- prop_basic AS prop
- FROM events AS e
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-31 00:00:00.000000', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@laterevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
diff --git a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.new_events_schema.ambr
deleted file mode 100644
index 770478618d0e..000000000000
--- a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.new_events_schema.ambr
+++ /dev/null
@@ -1,622 +0,0 @@
-# serializer version: 1
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_0_person_id_override_properties_on_events_no_filter[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.person_properties.email, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.person_properties.email), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))))), '%@posthog.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_1_person_id_override_properties_on_events_filter_earlierevent[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.person_properties.email, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.person_properties.email), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))))), '%@earlierevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_2_person_id_override_properties_on_events_filter_laterevent[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.person_properties.email, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.person_properties.email), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))))), '%@laterevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_3_person_id_override_properties_joined_no_filter[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(e__person.properties___email), '%@posthog.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_4_person_id_override_properties_joined_filter_earlierevent[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(e__person.properties___email), '%@earlierevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_5_person_id_override_properties_joined_filter_laterevent[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.id)
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(e__person.properties___email), '%@laterevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_6_person_id_no_override_properties_on_events_no_filter[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- e.person_id AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-31 00:00:00.000000', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.person_properties.email, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.person_properties.email), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))))), '%@posthog.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_7_person_id_no_override_properties_on_events_filter_earlierevent[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- e.person_id AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-31 00:00:00.000000', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.person_properties.email, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.person_properties.email), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))))), '%@earlierevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentFunnelsQueryRunner.test_query_runner_with_persons_on_events_mode_8_person_id_no_override_properties_on_events_filter_laterevent[new_events_schema]
- '''
- SELECT sum(step_1) AS step_1,
- sum(step_2) AS step_2,
- arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,
- arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,
- groupArray(row_number) AS row_number,
- final_prop AS final_prop
- FROM
- (SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,
- countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,
- groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,
- groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,
- rowNumberInAllBlocks() AS row_number,
- if(less(row_number, 25), breakdown, ['Other']) AS final_prop
- FROM
- (SELECT arraySort(t -> t.1, groupArray(tuple(accurateCastOrNull(timestamp, 'Float64'), uuid, arrayMap(x -> ifNull(x, ''), prop_basic), arrayFilter(x -> ifNull(notEquals(x, 0), 1), [multiply(1, step_0), multiply(2, step_1)])))) AS events_array,
- argMinIf(prop_basic, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop_basic))) AS prop,
- arrayJoin(aggregate_funnel_array(2, 1209600, 'first_touch', 'ordered', [if(empty(prop), [''], prop)], [], arrayFilter((x, x_before, x_after) -> not(and(lessOrEquals(length(x.4), 1), equals(x.4, x_before.4), equals(x.4, x_after.4), equals(x.3, x_before.3), equals(x.3, x_after.3), ifNull(greater(x.1, x_before.1), 0), ifNull(less(x.1, x_after.1), 0))), events_array, arrayRotateRight(events_array, 1), arrayRotateLeft(events_array, 1)))) AS af_tuple,
- af_tuple.1 AS step_reached,
- plus(af_tuple.1, 1) AS steps,
- af_tuple.2 AS breakdown,
- af_tuple.3 AS timings,
- af_tuple.5 AS steps_bitfield,
- aggregation_target AS aggregation_target
- FROM
- (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp,
- e.person_id AS aggregation_target,
- e.uuid AS uuid,
- e.properties.`$session_id` AS `$session_id`,
- e.properties.`$window_id` AS `$window_id`,
- if(equals(e.event, '$pageview'), 1, 0) AS step_0,
- if(equals(e.event, 'purchase'), 1, 0) AS step_1,
- [ifNull(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), '')] AS prop_basic,
- prop_basic AS prop
- FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), and(and(greaterOrEquals(e.timestamp, toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(e.timestamp, toDateTime64('2020-01-31 00:00:00.000000', 6, 'UTC'))), in(e.event, tuple('$pageview', 'purchase')), ifNull(notILike(toString(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.person_properties.^email)), if(isNull(nullIf(toString(e.person_properties.email), '')), NULL, if(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.person_properties.email, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.person_properties.email), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.person_properties.email, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.person_properties.email), '[]'), '{}'), toString(e.person_properties.email)))))), '%@laterevent.com%'), 1)), or(equals(step_0, 1), equals(step_1, 1))))
- GROUP BY aggregation_target
- HAVING ifNull(greaterOrEquals(step_reached, 0), 0))
- GROUP BY breakdown
- ORDER BY step_2 DESC,
- step_1 DESC)
- GROUP BY final_prop
- ORDER BY step_2 DESC,
- step_1 DESC
- LIMIT 26 SETTINGS join_algorithm='auto',
- readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=23622320128,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
diff --git a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_trends_query_runner.ambr b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_trends_query_runner.ambr
deleted file mode 100644
index 9fa8da60438a..000000000000
--- a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_trends_query_runner.ambr
+++ /dev/null
@@ -1,112 +0,0 @@
-# serializer version: 1
-# name: TestExperimentTrendsQueryRunner.test_query_runner_with_action
- '''
- SELECT groupArray(1)(date)[1] AS date,
- arrayFold((acc, x) -> arrayMap(i -> plus(acc[i], x[i]), range(1, plus(length(date), 1))), groupArray(ifNull(total, 0)), arrayWithConstant(length(date), reinterpretAsFloat64(0))) AS total,
- if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', breakdown_value) AS breakdown_value
- FROM
- (SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC')), toIntervalDay(1)))), 1))) AS date,
- arrayFill(x -> ifNull(greater(x, 0), 0), arrayMap(_match_date -> arraySum(arraySlice(groupArray(ifNull(count, 0)), indexOf(groupArray(day_start) AS _days_for_count, _match_date) AS _index, plus(minus(arrayLastIndex(x -> ifNull(equals(x, _match_date), isNull(x)
- and isNull(_match_date)), _days_for_count), _index), 1))), date)) AS total,
- breakdown_value AS breakdown_value,
- rowNumberInAllBlocks() AS row_number
- FROM
- (SELECT day_start AS day_start,
- sum(count) OVER (PARTITION BY breakdown_value
- ORDER BY day_start ASC) AS count,
- breakdown_value AS breakdown_value
- FROM
- (SELECT sum(total) AS count,
- day_start AS day_start,
- breakdown_value AS breakdown_value
- FROM
- (SELECT count() AS total,
- toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', '')), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
- FROM events AS e
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(e.event, '$pageview'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature/test-experiment'), ''), 'null'), '^"|"$', ''), tuple('control', 'test')))
- GROUP BY day_start,
- breakdown_value)
- GROUP BY day_start,
- breakdown_value
- ORDER BY day_start ASC,
- breakdown_value ASC)
- ORDER BY day_start ASC)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC)
- WHERE isNotNull(breakdown_value)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC
- LIMIT 50000 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentTrendsQueryRunner.test_query_runner_with_action.1
- '''
- SELECT groupArray(1)(date)[1] AS date,
- arrayFold((acc, x) -> arrayMap(i -> plus(acc[i], x[i]), range(1, plus(length(date), 1))), groupArray(ifNull(total, 0)), arrayWithConstant(length(date), reinterpretAsFloat64(0))) AS total,
- if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', breakdown_value) AS breakdown_value
- FROM
- (SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC')), toIntervalDay(1)))), 1))) AS date,
- arrayFill(x -> ifNull(greater(x, 0), 0), arrayMap(_match_date -> arraySum(arraySlice(groupArray(ifNull(count, 0)), indexOf(groupArray(day_start) AS _days_for_count, _match_date) AS _index, plus(minus(arrayLastIndex(x -> ifNull(equals(x, _match_date), isNull(x)
- and isNull(_match_date)), _days_for_count), _index), 1))), date)) AS total,
- breakdown_value AS breakdown_value,
- rowNumberInAllBlocks() AS row_number
- FROM
- (SELECT day_start AS day_start,
- sum(count) OVER (PARTITION BY breakdown_value
- ORDER BY day_start ASC) AS count,
- breakdown_value AS breakdown_value
- FROM
- (SELECT sum(total) AS count,
- day_start AS day_start,
- breakdown_value AS breakdown_value
- 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(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature_flag_response'), ''), 'null'), '^"|"$', '')), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
- FROM events AS e
- LEFT OUTER JOIN
- (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(e.event, '$feature_flag_called'), and(in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature_flag_response'), ''), 'null'), '^"|"$', ''), tuple('control', 'test')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$feature_flag'), ''), 'null'), '^"|"$', ''), 'test-experiment'), 0)))
- GROUP BY if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id),
- breakdown_value)
- GROUP BY day_start,
- breakdown_value
- ORDER BY day_start ASC,
- breakdown_value ASC)
- ORDER BY day_start ASC)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC)
- WHERE isNotNull(breakdown_value)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC
- LIMIT 50000 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
diff --git a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_trends_query_runner.new_events_schema.ambr b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_trends_query_runner.new_events_schema.ambr
deleted file mode 100644
index b2429f00d11f..000000000000
--- a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_trends_query_runner.new_events_schema.ambr
+++ /dev/null
@@ -1,112 +0,0 @@
-# serializer version: 1
-# name: TestExperimentTrendsQueryRunner.test_query_runner_with_action[new_events_schema.1]
- '''
- SELECT groupArray(1)(date)[1] AS date,
- arrayFold((acc, x) -> arrayMap(i -> plus(acc[i], x[i]), range(1, plus(length(date), 1))), groupArray(ifNull(total, 0)), arrayWithConstant(length(date), reinterpretAsFloat64(0))) AS total,
- if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', breakdown_value) AS breakdown_value
- FROM
- (SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC')), toIntervalDay(1)))), 1))) AS date,
- arrayFill(x -> ifNull(greater(x, 0), 0), arrayMap(_match_date -> arraySum(arraySlice(groupArray(ifNull(count, 0)), indexOf(groupArray(day_start) AS _days_for_count, _match_date) AS _index, plus(minus(arrayLastIndex(x -> ifNull(equals(x, _match_date), isNull(x)
- and isNull(_match_date)), _days_for_count), _index), 1))), date)) AS total,
- breakdown_value AS breakdown_value,
- rowNumberInAllBlocks() AS row_number
- FROM
- (SELECT day_start AS day_start,
- sum(count) OVER (PARTITION BY breakdown_value
- ORDER BY day_start ASC) AS count,
- breakdown_value AS breakdown_value
- FROM
- (SELECT sum(total) AS count,
- day_start AS day_start,
- breakdown_value AS breakdown_value
- 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(JSONStripEmptyStringsAndNulls(toJSONString(e.properties.^`$feature_flag_response`)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.properties.^`$feature_flag_response`)), if(isNull(nullIf(toString(e.properties.`$feature_flag_response`), '')), NULL, if(startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.properties.`$feature_flag_response`, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.properties.`$feature_flag_response`), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.properties.`$feature_flag_response`), '[]'), '{}'), toString(e.properties.`$feature_flag_response`)))))), 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,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id)
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(e.event, '$feature_flag_called'), and(in(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.properties.^`$feature_flag_response`)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.properties.^`$feature_flag_response`)), if(isNull(nullIf(toString(e.properties.`$feature_flag_response`), '')), NULL, if(startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.properties.`$feature_flag_response`, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.properties.`$feature_flag_response`), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.properties.`$feature_flag_response`, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.properties.`$feature_flag_response`), '[]'), '{}'), toString(e.properties.`$feature_flag_response`))))), tuple('control', 'test')), ifNull(equals(if(notEquals(JSONStripEmptyStringsAndNulls(toJSONString(e.properties.^`$feature_flag`)), '{}'), JSONStripEmptyStringsAndNulls(toJSONString(e.properties.^`$feature_flag`)), if(isNull(nullIf(toString(e.properties.`$feature_flag`), '')), NULL, if(startsWith(dynamicType(accurateCast(e.properties.`$feature_flag`, 'Dynamic')), 'DateTime'), concat(ifNull(toString(replaceOne(substring(toString(accurateCastOrNull(e.properties.`$feature_flag`, 'DateTime64(9, \'UTC\')')), 1, 19), ' ', 'T')), ''), ifNull(toString(substring(toString(e.properties.`$feature_flag`), 20, 10)), ''), 'Z'), if(or(startsWith(dynamicType(accurateCast(e.properties.`$feature_flag`, 'Dynamic')), 'Array'), startsWith(dynamicType(accurateCast(e.properties.`$feature_flag`, 'Dynamic')), 'Map'), startsWith(dynamicType(accurateCast(e.properties.`$feature_flag`, 'Dynamic')), 'Tuple')), nullIf(nullIf(toJSONString(e.properties.`$feature_flag`), '[]'), '{}'), toString(e.properties.`$feature_flag`))))), 'test-experiment'), 0)))
- GROUP BY if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id),
- breakdown_value)
- GROUP BY day_start,
- breakdown_value
- ORDER BY day_start ASC,
- breakdown_value ASC)
- ORDER BY day_start ASC)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC)
- WHERE isNotNull(breakdown_value)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC
- LIMIT 50000 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestExperimentTrendsQueryRunner.test_query_runner_with_action[new_events_schema]
- '''
- SELECT groupArray(1)(date)[1] AS date,
- arrayFold((acc, x) -> arrayMap(i -> plus(acc[i], x[i]), range(1, plus(length(date), 1))), groupArray(ifNull(total, 0)), arrayWithConstant(length(date), reinterpretAsFloat64(0))) AS total,
- if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', breakdown_value) AS breakdown_value
- FROM
- (SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC')), toIntervalDay(1)))), 1))) AS date,
- arrayFill(x -> ifNull(greater(x, 0), 0), arrayMap(_match_date -> arraySum(arraySlice(groupArray(ifNull(count, 0)), indexOf(groupArray(day_start) AS _days_for_count, _match_date) AS _index, plus(minus(arrayLastIndex(x -> ifNull(equals(x, _match_date), isNull(x)
- and isNull(_match_date)), _days_for_count), _index), 1))), date)) AS total,
- breakdown_value AS breakdown_value,
- rowNumberInAllBlocks() AS row_number
- FROM
- (SELECT day_start AS day_start,
- sum(count) OVER (PARTITION BY breakdown_value
- ORDER BY day_start ASC) AS count,
- breakdown_value AS breakdown_value
- FROM
- (SELECT sum(total) AS count,
- day_start AS day_start,
- breakdown_value AS breakdown_value
- FROM
- (SELECT count() AS total,
- toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start,
- ifNull(nullIf(leftUTF8(toString(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL)), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value
- FROM events_json AS e
- WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-01 12:00:00', 'UTC'))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2020-01-15 12:00:00', 'UTC'))), equals(e.event, '$pageview'), in(if(has(e.properties.`$feature_flags`, 'test-experiment'), if(ifNull(equals(e.properties.`$feature_flags`['test-experiment'], '$false'), 0), 'false', e.properties.`$feature_flags`['test-experiment']), NULL), tuple('control', 'test')))
- GROUP BY day_start,
- breakdown_value)
- GROUP BY day_start,
- breakdown_value
- ORDER BY day_start ASC,
- breakdown_value ASC)
- ORDER BY day_start ASC)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC)
- WHERE isNotNull(breakdown_value)
- GROUP BY breakdown_value
- ORDER BY if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_other_$$'), 0), 2, if(ifNull(equals(breakdown_value, '$$_posthog_breakdown_null_$$'), 0), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC
- LIMIT 50000 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- optimize_rewrite_aggregate_function_with_if=0,
- optimize_min_inequality_conjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
diff --git a/products/experiments/backend/hogql_queries/test/test_experiment_funnels_query_runner.py b/products/experiments/backend/hogql_queries/test/test_experiment_funnels_query_runner.py
deleted file mode 100644
index 7500de7d0d68..000000000000
--- a/products/experiments/backend/hogql_queries/test/test_experiment_funnels_query_runner.py
+++ /dev/null
@@ -1,811 +0,0 @@
-import json
-from datetime import datetime, timedelta
-from typing import cast
-
-import pytest
-import time_machine
-from posthog.test.base import (
- APIBaseTest,
- ClickhouseTestMixin,
- _create_event,
- _create_person,
- create_person_id_override_by_distinct_id,
- flush_persons_and_events,
- snapshot_clickhouse_queries,
-)
-
-from django.utils import timezone
-
-from parameterized import parameterized
-from rest_framework.exceptions import ValidationError
-
-from posthog.schema import (
- BreakdownAttributionType,
- EventsNode,
- ExperimentFunnelsQuery,
- ExperimentSignificanceCode,
- FunnelsQuery,
- PersonsOnEventsMode,
-)
-
-from posthog.constants import ExperimentNoResultsErrorKeys
-from posthog.test.test_journeys import journeys_for
-
-from products.experiments.backend.hogql_queries.experiment_funnels_query_runner import ExperimentFunnelsQueryRunner
-from products.experiments.backend.models.experiment import Experiment, ExperimentHoldout
-from products.feature_flags.backend.models.feature_flag import FeatureFlag
-
-
-class TestExperimentFunnelsQueryRunner(ClickhouseTestMixin, APIBaseTest):
- def create_feature_flag(self, key="test-experiment"):
- return FeatureFlag.objects.create(
- name=f"Test experiment flag: {key}",
- key=key,
- team=self.team,
- filters={
- "groups": [{"properties": [], "rollout_percentage": None}],
- "multivariate": {
- "variants": [
- {
- "key": "control",
- "name": "Control",
- "rollout_percentage": 50,
- },
- {
- "key": "test",
- "name": "Test",
- "rollout_percentage": 50,
- },
- ]
- },
- },
- created_by=self.user,
- )
-
- def create_experiment(self, name="test-experiment", feature_flag=None, start_date=None, end_date=None):
- if feature_flag is None:
- feature_flag = self.create_feature_flag(name)
- if start_date is None:
- start_date = timezone.now()
- else:
- start_date = timezone.make_aware(start_date) # Make naive datetime timezone-aware
- if end_date is None:
- end_date = timezone.now() + timedelta(days=14)
- elif end_date is not None:
- end_date = timezone.make_aware(end_date) # Make naive datetime timezone-aware
- return Experiment.objects.create(
- name=name,
- team=self.team,
- feature_flag=feature_flag,
- start_date=start_date,
- end_date=end_date,
- )
-
- def create_holdout_for_experiment(self, experiment):
- holdout = ExperimentHoldout.objects.create(
- team=self.team,
- name="Test Experiment holdout",
- )
- holdout.filters = [{"properties": [], "rollout_percentage": 20, "variant": f"holdout-{holdout.id}"}]
- holdout.save()
- experiment.holdout = holdout
- experiment.save()
- return holdout
-
- def test_deleted_feature_flag_tombstone_uses_original_key_in_prepared_query(self):
- feature_flag = self.create_feature_flag(key="deleted-funnels-flag")
- experiment = self.create_experiment(feature_flag=feature_flag)
- original_key = feature_flag.key
- feature_flag.key = f"{original_key}:deleted:{feature_flag.id}"
- feature_flag.deleted = True
- feature_flag.save(update_fields=["key", "deleted"])
-
- query_runner = ExperimentFunnelsQueryRunner(
- query=ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- ),
- ),
- team=self.team,
- )
-
- assert query_runner.prepared_funnels_query.breakdownFilter is not None
- self.assertEqual(
- query_runner.prepared_funnels_query.breakdownFilter.breakdown,
- f"$feature/{original_key}",
- )
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- feature_flag_property = f"$feature/{feature_flag.key}"
-
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- )
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- for variant, purchase_count in [("control", 6), ("test", 8)]:
- for i in range(10):
- _create_person(distinct_ids=[f"user_{variant}_{i}"], team_id=self.team.pk)
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id=f"user_{variant}_{i}",
- timestamp="2020-01-02T12:00:00Z",
- properties={feature_flag_property: variant},
- )
- if i < purchase_count:
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id=f"user_{variant}_{i}",
- timestamp="2020-01-02T12:01:00Z",
- properties={feature_flag_property: variant},
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentFunnelsQueryRunner(
- query=ExperimentFunnelsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 2)
-
- control_variant = next(variant for variant in result.variants if variant.key == "control")
- test_variant = next(variant for variant in result.variants if variant.key == "test")
-
- self.assertEqual(control_variant.success_count, 6)
- self.assertEqual(control_variant.failure_count, 4)
- self.assertEqual(test_variant.success_count, 8)
- self.assertEqual(test_variant.failure_count, 2)
-
- self.assertAlmostEqual(result.probability["control"], 0.2, delta=0.1)
- self.assertAlmostEqual(result.probability["test"], 0.8, delta=0.1)
-
- self.assertEqual(result.significant, False)
- self.assertEqual(result.significance_code, ExperimentSignificanceCode.NOT_ENOUGH_EXPOSURE)
- self.assertEqual(result.expected_loss, 1.0)
-
- self.assertAlmostEqual(result.credible_intervals["control"][0], 0.3, delta=0.1)
- self.assertAlmostEqual(result.credible_intervals["control"][1], 0.8, delta=0.1)
- self.assertAlmostEqual(result.credible_intervals["test"][0], 0.5, delta=0.1)
- self.assertAlmostEqual(result.credible_intervals["test"][1], 0.9, delta=0.1)
-
- @pytest.mark.flaky(reruns=9)
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_standard_flow(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- )
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- "user_control_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "control"}},
- ],
- "user_control_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- ],
- "user_control_3": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "control"}},
- ],
- "user_test_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- ],
- "user_test_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- ],
- "user_test_3": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- ],
- "user_test_4": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentFunnelsQueryRunner(
- query=ExperimentFunnelsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 2)
- for variant in result.variants:
- self.assertIn(variant.key, ["control", "test"])
-
- control_variant = next(v for v in result.variants if v.key == "control")
- test_variant = next(v for v in result.variants if v.key == "test")
-
- self.assertEqual(control_variant.success_count, 2)
- self.assertEqual(control_variant.failure_count, 1)
- self.assertEqual(test_variant.success_count, 3)
- self.assertEqual(test_variant.failure_count, 1)
-
- self.assertAlmostEqual(result.probability["control"], 0.407, places=2)
- self.assertAlmostEqual(result.probability["test"], 0.593, places=2)
-
- self.assertAlmostEqual(result.credible_intervals["control"][0], 0.1941, places=3)
- self.assertAlmostEqual(result.credible_intervals["control"][1], 0.9324, places=3)
- self.assertAlmostEqual(result.credible_intervals["test"][0], 0.2836, places=3)
- self.assertAlmostEqual(result.credible_intervals["test"][1], 0.9473, places=3)
-
- self.assertEqual(result.significance_code, ExperimentSignificanceCode.NOT_ENOUGH_EXPOSURE)
-
- self.assertFalse(result.significant)
- self.assertEqual(len(result.variants), 2)
- self.assertAlmostEqual(result.expected_loss, 1.0, places=1)
-
- @parameterized.expand(
- [
- [
- BreakdownAttributionType.FIRST_TOUCH,
- # 8 total
- {
- "control_success": 3,
- "control_failure": 1,
- "test_success": 3,
- "test_failure": 1,
- },
- ],
- [
- BreakdownAttributionType.LAST_TOUCH,
- # 8 total
- {
- "control_success": 3,
- "control_failure": 1,
- "test_success": 3,
- "test_failure": 1,
- },
- ],
- [
- BreakdownAttributionType.ALL_EVENTS,
- # 9 total (one duplicated)
- {
- "control_success": 3,
- "control_failure": 1,
- "test_success": 3,
- "test_failure": 2,
- },
- ],
- [
- BreakdownAttributionType.STEP,
- # 7 total
- {
- "control_success": 3,
- "control_failure": 0,
- "test_success": 4,
- "test_failure": 1,
- },
- ],
- ]
- )
- @time_machine.travel("2020-01-01T00:00:00Z", tick=False)
- def test_query_runner_attribution(self, attribution_type, expected_counts):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- # use the second step when testing step attribution
- attribution_value = 1 if attribution_type == BreakdownAttributionType.STEP else 0
-
- ff_property = f"$feature/{feature_flag.key}"
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="seen"), EventsNode(event="signup"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- funnelsFilter={
- "breakdownAttributionType": attribution_type,
- "breakdownAttributionValue": attribution_value,
- "funnelVizType": "steps",
- "funnelWindowInterval": "14",
- "funnelWindowIntervalUnit": "day",
- "layout": "horizontal",
- },
- )
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- # control success always
- "user_control_1": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "signup", "timestamp": "2020-01-03", "properties": {ff_property: "control"}},
- {"event": "purchase", "timestamp": "2020-01-04", "properties": {ff_property: "control"}},
- ],
- # control failure for "first_touch", "last_touch", and "all_events"
- # dropped for "steps"
- "user_control_2": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- # Doesn't sign up or make a purchase
- ],
- # control success always
- "user_control_3": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "signup", "timestamp": "2020-01-03", "properties": {ff_property: "control"}},
- {"event": "purchase", "timestamp": "2020-01-04", "properties": {ff_property: "control"}},
- ],
- # control success for "first_touch", "last_touch"
- # counted twice for for "all_events"
- # test success for "steps"
- "user_mixed_4": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "seen", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- {"event": "signup", "timestamp": "2020-01-04", "properties": {ff_property: "control"}},
- {"event": "signup", "timestamp": "2020-01-05", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-06", "properties": {ff_property: "control"}},
- ],
- # test success always
- "user_test_5": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "signup", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-04", "properties": {ff_property: "test"}},
- ],
- # test success always
- "user_test_6": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "signup", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-04", "properties": {ff_property: "test"}},
- ],
- # test failure always
- "user_test_7": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "signup", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- # Doesn't make a purchase
- ],
- # test success always
- "user_test_8": [
- {"event": "seen", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "signup", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-04", "properties": {ff_property: "test"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentFunnelsQueryRunner(
- query=ExperimentFunnelsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 2)
- control_variant = next(v for v in result.variants if v.key == "control")
- test_variant = next(v for v in result.variants if v.key == "test")
-
- self.assertEqual(control_variant.success_count, expected_counts["control_success"])
- self.assertEqual(control_variant.failure_count, expected_counts["control_failure"])
- self.assertEqual(test_variant.success_count, expected_counts["test_success"])
- self.assertEqual(test_variant.failure_count, expected_counts["test_failure"])
-
- @parameterized.expand(
- [
- ###
- # PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS
- ###
- [
- "person_id_override_properties_on_events_no_filter",
- PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS,
- None,
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 1,
- "test_failure": 0,
- },
- ],
- [
- "person_id_override_properties_on_events_filter_earlierevent",
- PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS,
- {
- "key": "email",
- "value": "@earlierevent.com",
- "operator": "not_icontains",
- "type": "person",
- },
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 1,
- "test_failure": 0,
- },
- ],
- [
- "person_id_override_properties_on_events_filter_laterevent",
- PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS,
- {
- "key": "email",
- "value": "@laterevent.com",
- "operator": "not_icontains",
- "type": "person",
- },
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 0,
- "test_failure": 1,
- },
- ],
- ###
- # PERSON_ID_OVERRIDE_PROPERTIES_JOINED
- ###
- [
- "person_id_override_properties_joined_no_filter",
- PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_JOINED,
- None,
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 1,
- "test_failure": 0,
- },
- ],
- [
- "person_id_override_properties_joined_filter_earlierevent",
- PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_JOINED,
- {
- "key": "email",
- "value": "@earlierevent.com",
- "operator": "not_icontains",
- "type": "person",
- },
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 1,
- "test_failure": 0,
- },
- ],
- [
- "person_id_override_properties_joined_filter_laterevent",
- PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_JOINED,
- {
- "key": "email",
- "value": "@laterevent.com",
- "operator": "not_icontains",
- "type": "person",
- },
- None,
- ],
- ###
- # PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS
- ###
- [
- "person_id_no_override_properties_on_events_no_filter",
- PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS,
- None,
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 1,
- "test_failure": 1,
- },
- ],
- [
- "person_id_no_override_properties_on_events_filter_earlierevent",
- PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS,
- {
- "key": "email",
- "value": "@earlierevent.com",
- "operator": "not_icontains",
- "type": "person",
- },
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 1,
- "test_failure": 0,
- },
- ],
- [
- "person_id_no_override_properties_on_events_filter_laterevent",
- PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS,
- {
- "key": "email",
- "value": "@laterevent.com",
- "operator": "not_icontains",
- "type": "person",
- },
- {
- "control_success": 1,
- "control_failure": 0,
- "test_success": 0,
- "test_failure": 1,
- },
- ],
- ]
- )
- @snapshot_clickhouse_queries
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_with_persons_on_events_mode(self, name, persons_on_events_mode, filters, expected_results):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(
- feature_flag=feature_flag, start_date=datetime(2020, 1, 1), end_date=datetime(2020, 1, 31)
- )
-
- feature_flag_property = f"$feature/{feature_flag.key}"
-
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-31"},
- filterTestAccounts=True,
- )
-
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- ## Control isn't affected by the filter
- _create_person(distinct_ids=["user_control_1"], team_id=self.team.pk)
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id="user_control_1",
- timestamp="2020-01-02T12:00:00Z",
- properties={feature_flag_property: "control"},
- )
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id="user_control_1",
- timestamp="2020-01-02T12:01:00Z",
- properties={feature_flag_property: "control"},
- )
-
- ## Test is tied to person on events mode
- _create_person(
- distinct_ids=["person_id_1_distinct_id_1"],
- properties={"email": "[email protected]"},
- team_id=self.team.pk,
- )
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id="person_id_1_distinct_id_1",
- timestamp="2020-01-02T12:00:00Z",
- properties={feature_flag_property: "test"},
- )
- _create_person(
- distinct_ids=["person_id_1_distinct_id_2"],
- properties={"email": "[email protected]"},
- team_id=self.team.pk,
- )
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id="person_id_1_distinct_id_2",
- timestamp="2020-01-02T12:01:00Z",
- properties={feature_flag_property: "test"},
- )
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id="person_id_1_distinct_id_2",
- timestamp="2020-01-02T12:02:00Z",
- properties={feature_flag_property: "test"},
- )
- create_person_id_override_by_distinct_id("person_id_1_distinct_id_1", "person_id_1_distinct_id_2", self.team.pk)
-
- flush_persons_and_events()
-
- self.team.modifiers = {"personsOnEventsMode": persons_on_events_mode}
- if filters:
- self.team.test_account_filters = [filters]
- self.team.save()
-
- query_runner = ExperimentFunnelsQueryRunner(
- query=ExperimentFunnelsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- if expected_results is None:
- with self.assertRaises(ValidationError):
- query_runner.calculate()
- else:
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 2)
- control_variant = next(v for v in result.variants if v.key == "control")
- test_variant = next(v for v in result.variants if v.key == "test")
-
- self.assertEqual(
- {
- "control_success": int(control_variant.success_count),
- "control_failure": int(control_variant.failure_count),
- "test_success": int(test_variant.success_count),
- "test_failure": int(test_variant.failure_count),
- },
- expected_results,
- )
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_with_holdout(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
- holdout = self.create_holdout_for_experiment(experiment)
-
- feature_flag_property = f"$feature/{feature_flag.key}"
-
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- )
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- for variant, purchase_count in [("control", 6), ("test", 8), (f"holdout-{holdout.id}", 3)]:
- for i in range(10):
- _create_person(distinct_ids=[f"user_{variant}_{i}"], team_id=self.team.pk)
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id=f"user_{variant}_{i}",
- timestamp="2020-01-02T12:00:00Z",
- properties={feature_flag_property: variant},
- )
- if i < purchase_count:
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id=f"user_{variant}_{i}",
- timestamp="2020-01-02T12:01:00Z",
- properties={feature_flag_property: variant},
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentFunnelsQueryRunner(
- query=ExperimentFunnelsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 3)
-
- control_variant = next(variant for variant in result.variants if variant.key == "control")
- test_variant = next(variant for variant in result.variants if variant.key == "test")
- holdout_variant = next(variant for variant in result.variants if variant.key == f"holdout-{holdout.id}")
-
- self.assertEqual(control_variant.success_count, 6)
- self.assertEqual(control_variant.failure_count, 4)
- self.assertEqual(test_variant.success_count, 8)
- self.assertEqual(test_variant.failure_count, 2)
- self.assertEqual(holdout_variant.success_count, 3)
- self.assertEqual(holdout_variant.failure_count, 7)
-
- self.assertIn("control", result.probability)
- self.assertIn("test", result.probability)
- self.assertIn(f"holdout-{holdout.id}", result.probability)
-
- self.assertIn("control", result.credible_intervals)
- self.assertIn("test", result.credible_intervals)
- self.assertIn(f"holdout-{holdout.id}", result.credible_intervals)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_validate_event_variants_no_control(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- journeys_for(
- {
- "user_test": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- )
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- query_runner = ExperimentFunnelsQueryRunner(query=experiment_query, team=self.team)
- with self.assertRaises(ValidationError) as context:
- query_runner.calculate()
-
- expected_errors = json.dumps(
- {
- ExperimentNoResultsErrorKeys.NO_CONTROL_VARIANT: True,
- ExperimentNoResultsErrorKeys.NO_TEST_VARIANT: False,
- }
- )
- self.assertEqual(cast(list, context.exception.detail)[0], expected_errors)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_validate_event_variants_no_test(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- journeys_for(
- {
- "user_control": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "purchase", "timestamp": "2020-01-03", "properties": {ff_property: "control"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- funnels_query = FunnelsQuery(
- series=[EventsNode(event="$pageview"), EventsNode(event="purchase")],
- dateRange={"date_from": "2020-01-01", "date_to": "2020-01-14"},
- )
- experiment_query = ExperimentFunnelsQuery(
- experiment_id=experiment.id,
- kind="ExperimentFunnelsQuery",
- funnels_query=funnels_query,
- )
-
- query_runner = ExperimentFunnelsQueryRunner(query=experiment_query, team=self.team)
- with self.assertRaises(ValidationError) as context:
- query_runner.calculate()
-
- expected_errors = json.dumps(
- {
- ExperimentNoResultsErrorKeys.NO_CONTROL_VARIANT: False,
- ExperimentNoResultsErrorKeys.NO_TEST_VARIANT: True,
- }
- )
- self.assertEqual(cast(list, context.exception.detail)[0], expected_errors)
diff --git a/products/experiments/backend/hogql_queries/test/test_experiment_trends_query_runner.py b/products/experiments/backend/hogql_queries/test/test_experiment_trends_query_runner.py
deleted file mode 100644
index c01415b4ac10..000000000000
--- a/products/experiments/backend/hogql_queries/test/test_experiment_trends_query_runner.py
+++ /dev/null
@@ -1,1412 +0,0 @@
-import json
-from datetime import datetime, timedelta
-from typing import Any, cast
-
-import pytest
-import time_machine
-from posthog.test.base import (
- APIBaseTest,
- ClickhouseTestMixin,
- _create_event,
- _create_person,
- flush_persons_and_events,
- snapshot_clickhouse_queries,
-)
-
-from django.test import override_settings
-from django.utils import timezone
-
-from parameterized import parameterized
-from rest_framework.exceptions import ValidationError
-
-from posthog.schema import (
- ActionsNode,
- BaseMathType,
- EventPropertyFilter,
- EventsNode,
- ExperimentSignificanceCode,
- ExperimentTrendsQuery,
- ExperimentTrendsQueryResponse,
- PropertyMathType,
- TrendsQuery,
-)
-
-from posthog.constants import ExperimentNoResultsErrorKeys
-from posthog.models.group.util import create_group
-from posthog.test.test_journeys import journeys_for
-from posthog.test.test_utils import create_group_type_mapping_without_created_at
-
-from products.actions.backend.models.action import Action
-from products.cohorts.backend.models.cohort import Cohort
-from products.cohorts.backend.models.util import count_cohort_members
-from products.experiments.backend.hogql_queries.experiment_trends_query_runner import ExperimentTrendsQueryRunner
-from products.experiments.backend.hogql_queries.types import ExperimentMetricType
-from products.experiments.backend.models.experiment import Experiment, ExperimentHoldout
-from products.feature_flags.backend.models.feature_flag import FeatureFlag
-
-
-@override_settings(IN_UNIT_TESTING=True)
-class TestExperimentTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):
- def create_feature_flag(self, key="test-experiment"):
- return FeatureFlag.objects.create(
- name=f"Test experiment flag: {key}",
- key=key,
- team=self.team,
- filters={
- "groups": [{"properties": [], "rollout_percentage": None}],
- "multivariate": {
- "variants": [
- {
- "key": "control",
- "name": "Control",
- "rollout_percentage": 50,
- },
- {
- "key": "test",
- "name": "Test",
- "rollout_percentage": 50,
- },
- ]
- },
- },
- created_by=self.user,
- )
-
- def create_experiment(
- self,
- name="test-experiment",
- feature_flag=None,
- start_date=None,
- end_date=None,
- ):
- if feature_flag is None:
- feature_flag = self.create_feature_flag(name)
- if start_date is None:
- start_date = timezone.now()
- else:
- start_date = timezone.make_aware(start_date) # Make naive datetime timezone-aware
- if end_date is None:
- end_date = timezone.now() + timedelta(days=14)
- elif end_date is not None:
- end_date = timezone.make_aware(end_date) # Make naive datetime timezone-aware
- return Experiment.objects.create(
- name=name,
- team=self.team,
- feature_flag=feature_flag,
- start_date=start_date,
- end_date=end_date,
- )
-
- def create_holdout_for_experiment(self, experiment: Experiment):
- holdout = ExperimentHoldout.objects.create(
- team=self.team,
- name="Test Experiment holdout",
- )
- holdout.filters = [{"properties": [], "rollout_percentage": 20, "variant": f"holdout-{holdout.id}"}]
- holdout.save()
- experiment.holdout = holdout
- experiment.save()
- return holdout
-
- def test_deleted_feature_flag_tombstone_uses_original_key_in_prepared_queries(self):
- feature_flag = self.create_feature_flag(key="deleted-trends-flag")
- experiment = self.create_experiment(feature_flag=feature_flag)
- original_key = feature_flag.key
- feature_flag.key = f"{original_key}:deleted:{feature_flag.id}"
- feature_flag.deleted = True
- feature_flag.save(update_fields=["key", "deleted"])
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=TrendsQuery(series=[EventsNode(event="$pageview")]),
- exposure_query=None,
- ),
- team=self.team,
- )
-
- self.assertEqual(query_runner.breakdown_key, f"$feature/{original_key}")
- assert query_runner.prepared_count_query.breakdownFilter is not None
- self.assertEqual(query_runner.prepared_count_query.breakdownFilter.breakdown, f"$feature/{original_key}")
-
- exposure_properties = query_runner.prepared_exposure_query.properties
- assert exposure_properties is not None
- feature_flag_filter = cast(
- EventPropertyFilter,
- next(
- prop
- for prop in exposure_properties
- if isinstance(prop, EventPropertyFilter) and prop.key == "$feature_flag"
- ),
- )
- self.assertEqual(feature_flag_filter.value, [original_key])
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- feature_flag_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- # Populate experiment events
- for variant, count in [("control", 11), ("test", 15)]:
- for i in range(count):
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id=f"user_{variant}_{i}",
- properties={feature_flag_property: variant},
- )
-
- # Populate exposure events
- for variant, count in [("control", 7), ("test", 9)]:
- for i in range(count):
- _create_event(
- team=self.team,
- event="$feature_flag_called",
- distinct_id=f"user_{variant}_{i}",
- properties={
- "$feature_flag_response": variant,
- feature_flag_property: variant,
- "$feature_flag": feature_flag.key,
- },
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 2)
-
- control_result = next(variant for variant in result.variants if variant.key == "control")
- test_result = next(variant for variant in result.variants if variant.key == "test")
-
- self.assertEqual(control_result.count, 11)
- self.assertEqual(test_result.count, 15)
- self.assertEqual(control_result.absolute_exposure, 7)
- self.assertEqual(test_result.absolute_exposure, 9)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_with_custom_exposure(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- self.team.test_account_filters = [
- {
- "key": "$host",
- "type": "event",
- "value": "^(localhost|127\\.0\\.0\\.1)($|:)",
- "operator": "not_regex",
- },
- ]
- self.team.save()
-
- ff_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")], filterTestAccounts=True)
- exposure_query = TrendsQuery(
- series=[EventsNode(event="custom_exposure_event", properties=[{"key": "valid_exposure", "value": "true"}])],
- filterTestAccounts=True,
- )
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=exposure_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- "user_control_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "valid_exposure": "true"},
- },
- ],
- "user_control_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "valid_exposure": "true"},
- },
- ],
- "user_test_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "valid_exposure": "true"},
- },
- ],
- "user_test_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "valid_exposure": "true"},
- },
- ],
- "user_out_of_control": [
- {"event": "$pageview", "timestamp": "2020-01-02"},
- ],
- "user_out_of_control_exposure": [
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "valid_exposure": "false"},
- },
- ],
- "user_out_of_date_range": [
- {"event": "$pageview", "timestamp": "2019-01-01", "properties": {ff_property: "control"}},
- {
- "event": "custom_exposure_event",
- "timestamp": "2019-01-01",
- "properties": {ff_property: "control", "valid_exposure": "true"},
- },
- ],
- },
- self.team,
- )
-
- # Extraneous internal user exposure event
- _create_event(
- team=self.team,
- event="custom_exposure_event",
- distinct_id="internal_test_1",
- properties={
- "valid_exposure": "true",
- ff_property: "test",
- "$host": "localhost",
- },
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.count, 3)
- self.assertEqual(test_result.count, 5)
-
- self.assertEqual(control_result.absolute_exposure, 2)
- self.assertEqual(test_result.absolute_exposure, 2)
-
- # Run again with filterTestAccounts=False
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")], filterTestAccounts=False)
- exposure_query = TrendsQuery(
- series=[EventsNode(event="custom_exposure_event", properties=[{"key": "valid_exposure", "value": "true"}])],
- filterTestAccounts=False,
- )
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=exposure_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.count, 3)
- self.assertEqual(test_result.count, 5)
-
- self.assertEqual(control_result.absolute_exposure, 2)
- self.assertEqual(test_result.absolute_exposure, 3)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_with_custom_exposure_sum_math(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview", math="sum", math_property="amount")])
- exposure_query = TrendsQuery(
- series=[EventsNode(event="custom_exposure_event", properties=[{"key": "valid_exposure", "value": "true"}])]
- )
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=exposure_query,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- "user_control_1": [
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "amount": 100},
- },
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "amount": 200},
- },
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "valid_exposure": "true"},
- },
- ],
- "user_control_2": [
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "amount": 100},
- },
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "valid_exposure": "true"},
- },
- ],
- "user_test_1": [
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "amount": 100},
- },
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "amount": 200},
- },
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "amount": 300},
- },
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "valid_exposure": "true"},
- },
- ],
- "user_test_2": [
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "amount": 100},
- },
- {
- "event": "$pageview",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "amount": 200},
- },
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "test", "valid_exposure": "true"},
- },
- ],
- "user_out_of_control": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {"amount": 100}},
- ],
- "user_out_of_control_exposure": [
- {
- "event": "custom_exposure_event",
- "timestamp": "2020-01-02",
- "properties": {ff_property: "control", "valid_exposure": "false"},
- },
- ],
- "user_out_of_date_range": [
- {
- "event": "$pageview",
- "timestamp": "2019-01-01",
- "properties": {ff_property: "control", "amount": 100},
- },
- {
- "event": "custom_exposure_event",
- "timestamp": "2019-01-01",
- "properties": {ff_property: "control", "valid_exposure": "true"},
- },
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.count, 400)
- self.assertEqual(test_result.count, 900)
-
- self.assertEqual(control_result.absolute_exposure, 2)
- self.assertEqual(test_result.absolute_exposure, 2)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_with_default_exposure(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None, # No exposure query provided
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- "user_control_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "control", "$feature_flag": feature_flag.key},
- },
- ],
- "user_control_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "control", "$feature_flag": feature_flag.key},
- },
- ],
- "user_test_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "test", "$feature_flag": feature_flag.key},
- },
- ],
- "user_test_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "test", "$feature_flag": feature_flag.key},
- },
- ],
- "user_out_of_control": [
- {"event": "$pageview", "timestamp": "2020-01-02"},
- ],
- "user_out_of_control_exposure": [
- {"event": "$feature_flag_called", "timestamp": "2020-01-02"},
- ],
- "user_out_of_date_range": [
- {"event": "$pageview", "timestamp": "2019-01-01", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2019-01-01",
- "properties": {"$feature_flag_response": "control", "$feature_flag": feature_flag.key},
- },
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.count, 3)
- self.assertEqual(test_result.count, 5)
-
- self.assertEqual(control_result.absolute_exposure, 2)
- self.assertEqual(test_result.absolute_exposure, 2)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- @snapshot_clickhouse_queries
- def test_query_runner_with_action(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- action = Action.objects.create(name="pageview", team=self.team, steps_json=[{"event": "$pageview"}])
- action.save()
-
- ff_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[ActionsNode(id=action.id)])
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None, # No exposure query provided
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- "user_control_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "control", "$feature_flag": feature_flag.key},
- },
- ],
- "user_control_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "control", "$feature_flag": feature_flag.key},
- },
- ],
- "user_test_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "test", "$feature_flag": feature_flag.key},
- },
- ],
- "user_test_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {"$feature_flag_response": "test", "$feature_flag": feature_flag.key},
- },
- ],
- "user_out_of_control": [
- {"event": "$pageview", "timestamp": "2020-01-02"},
- ],
- "user_out_of_control_exposure": [
- {"event": "$feature_flag_called", "timestamp": "2020-01-02"},
- ],
- "user_out_of_date_range": [
- {"event": "$pageview", "timestamp": "2019-01-01", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2019-01-01",
- "properties": {"$feature_flag_response": "control", "$feature_flag": feature_flag.key},
- },
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.count, 3)
- self.assertEqual(test_result.count, 5)
-
- self.assertEqual(control_result.absolute_exposure, 2)
- self.assertEqual(test_result.absolute_exposure, 2)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_with_holdout(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
- holdout = self.create_holdout_for_experiment(experiment)
-
- feature_flag_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- # Populate experiment events
- for variant, count in [("control", 11), ("test", 15), (f"holdout-{holdout.id}", 8)]:
- for i in range(count):
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id=f"user_{variant}_{i}",
- properties={feature_flag_property: variant},
- )
-
- # Populate exposure events
- for variant, count in [("control", 7), ("test", 9), (f"holdout-{holdout.id}", 4)]:
- for i in range(count):
- _create_event(
- team=self.team,
- event="$feature_flag_called",
- distinct_id=f"user_{variant}_{i}",
- properties={
- "$feature_flag_response": variant,
- feature_flag_property: variant,
- "$feature_flag": feature_flag.key,
- },
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 3)
-
- control_result = next(variant for variant in result.variants if variant.key == "control")
- test_result = next(variant for variant in result.variants if variant.key == "test")
- holdout_result = next(variant for variant in result.variants if variant.key == f"holdout-{holdout.id}")
-
- self.assertEqual(control_result.count, 11)
- self.assertEqual(test_result.count, 15)
- self.assertEqual(holdout_result.count, 8)
- self.assertEqual(control_result.absolute_exposure, 7)
- self.assertEqual(test_result.absolute_exposure, 9)
- self.assertEqual(holdout_result.absolute_exposure, 4)
-
- @parameterized.expand(
- [
- [
- "person_properties",
- {
- "key": "email",
- "value": "@posthog.com",
- "operator": "not_icontains",
- "type": "person",
- },
- {
- "control_absolute_exposure": 12,
- "test_absolute_exposure": 15,
- },
- ],
- [
- "event_properties",
- {
- "key": "$host",
- "value": "^(localhost|127\\.0\\.0\\.1)($|:)",
- "operator": "not_regex",
- "type": "event",
- },
- {
- "control_absolute_exposure": 6,
- "test_absolute_exposure": 6,
- },
- ],
- [
- "feature_flags",
- {
- "key": "$feature/flag_doesnt_exist",
- "type": "event",
- "value": ["test", "control"],
- "operator": "exact",
- },
- {
- "control_absolute_exposure": 0,
- "test_absolute_exposure": 0,
- },
- ],
- [
- "cohort_static",
- {
- "key": "id",
- "type": "static-cohort",
- # value is generated in the test
- "value": None,
- "operator": "exact",
- },
- {
- "control_absolute_exposure": 2,
- "test_absolute_exposure": 1,
- },
- ],
- [
- "cohort_dynamic",
- {
- "key": "id",
- "type": "cohort",
- # value is generated in the test
- "value": None,
- "operator": "exact",
- },
- {
- "control_absolute_exposure": 2,
- "test_absolute_exposure": 1,
- },
- ],
- [
- "group",
- {
- "key": "name",
- "type": "group",
- # Value is generated in the test
- "value": None,
- "operator": "exact",
- "group_type_index": 0,
- },
- {
- "control_absolute_exposure": 8,
- "test_absolute_exposure": 10,
- },
- ],
- [
- "element",
- {
- "key": "tag_name",
- "type": "element",
- "value": ["button"],
- "operator": "exact",
- },
- {
- "control_absolute_exposure": 0,
- "test_absolute_exposure": 0,
- },
- ],
- ]
- )
- def test_query_runner_with_internal_filters(self, name: str, filter: dict, expected_results: dict):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- cohort = None
- if name == "cohort_static":
- cohort = Cohort.objects.create(
- team=self.team,
- name="cohort_static",
- is_static=True,
- )
- filter["value"] = cohort.pk
- elif name == "cohort_dynamic":
- cohort = Cohort.objects.create(
- team=self.team,
- name="cohort_dynamic",
- groups=[
- {
- "properties": [
- {"key": "email", "operator": "not_icontains", "value": "@posthog.com", "type": "person"},
- ]
- }
- ],
- )
- filter["value"] = cohort.pk
- elif name == "group":
- create_group_type_mapping_without_created_at(
- team=self.team, project_id=self.team.project_id, group_type="organization", group_type_index=0
- )
- create_group(
- team_id=self.team.pk,
- group_type_index=0,
- group_key="my_awesome_group",
- properties={"name": "Test Group"},
- )
- filter["value"] = ["Test Group"]
-
- self.team.test_account_filters = [filter]
- self.team.save()
-
- feature_flag_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")], filterTestAccounts=True)
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- # Populate count events
- for variant, count in [("control", 7), ("test", 9)]:
- for i in range(count):
- extra_properties = {"$host": "localhost", "$group_0": "my_awesome_group"} if i > 5 else {}
- _create_event(
- team=self.team,
- event="$pageview",
- distinct_id=f"user_{variant}_{i}",
- properties={feature_flag_property: variant, **extra_properties},
- )
-
- # Populate exposure events
- for variant, count in [("control", 14), ("test", 16)]:
- for i in range(count):
- extra_properties = {"$host": "localhost", "$group_0": "my_awesome_group"} if i > 5 else {}
- _create_event(
- team=self.team,
- event="$feature_flag_called",
- distinct_id=f"user_{variant}_{i}",
- properties={
- "$feature_flag_response": variant,
- "$feature_flag": feature_flag.key,
- **extra_properties,
- },
- )
-
- _create_person(
- team=self.team,
- distinct_ids=["user_control_1"],
- )
- _create_person(
- team=self.team,
- distinct_ids=["user_control_2"],
- )
- _create_person(
- team=self.team,
- distinct_ids=["user_control_3"],
- properties={"email": "[email protected]"},
- )
- _create_person(
- team=self.team,
- distinct_ids=["user_control_6"],
- properties={"email": "[email protected]"},
- )
- _create_person(
- team=self.team,
- distinct_ids=["user_test_2"],
- properties={"email": "[email protected]"},
- )
- _create_person(
- team=self.team,
- distinct_ids=["user_test_3"],
- )
-
- flush_persons_and_events()
-
- if name == "cohort_static" and cohort:
- cohort.insert_users_by_list(["user_control_1", "user_control_2", "user_test_2"])
- self.assertEqual(count_cohort_members(cohort.team_id, cohort.id, consistency="strong"), 3)
- elif name == "cohort_dynamic" and cohort:
- cohort.calculate_people_ch(pending_version=0)
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- # "feature_flags" and "element" filter out all events
- if name == "feature_flags" or name == "element":
- with self.assertRaises(ValidationError) as context:
- query_runner.calculate()
-
- expected_errors = json.dumps(
- {
- ExperimentNoResultsErrorKeys.NO_EXPOSURES: True,
- ExperimentNoResultsErrorKeys.NO_CONTROL_VARIANT: True,
- ExperimentNoResultsErrorKeys.NO_TEST_VARIANT: True,
- }
- )
- self.assertEqual(cast(list, context.exception.detail)[0], expected_errors)
- else:
- result = query_runner.calculate()
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.absolute_exposure, expected_results["control_absolute_exposure"])
- self.assertEqual(test_result.absolute_exposure, expected_results["test_absolute_exposure"])
-
- ## Run again with filterTestAccounts=False
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")], filterTestAccounts=False)
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- self.assertEqual(control_result.absolute_exposure, 14)
- self.assertEqual(test_result.absolute_exposure, 16)
-
- # Uses mirrored values for easy comparison with the avg-math scenario
- @time_machine.travel("2020-01-01T00:00:00Z", tick=False)
- def test_query_runner_with_avg_math_v2_stats(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
- experiment.save()
-
- feature_flag_property = f"$feature/{feature_flag.key}"
-
- count_query = TrendsQuery(
- series=[
- EventsNode(event="purchase", math="sum", math_property="amount", math_property_type="event_properties")
- ],
- )
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
-
- # Populate exposure events - same as data warehouse test
- for variant, count in [("control", 1), ("test", 3)]:
- for i in range(count):
- _create_event(
- team=self.team,
- event="$feature_flag_called",
- distinct_id=f"user_{variant}_{i}",
- properties={
- "$feature_flag_response": variant,
- feature_flag_property: variant,
- "$feature_flag": feature_flag.key,
- },
- timestamp=datetime(2020, 1, i + 1),
- )
-
- # Create purchase events with same amounts as data warehouse test
- # Control: 1 purchase of 100
- # Test: 3 purchases of 50, 75, and 80
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id="user_control_0",
- properties={feature_flag_property: "control", "amount": 100},
- timestamp=datetime(2020, 1, 2),
- )
-
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id="user_test_1",
- properties={feature_flag_property: "test", "amount": 50},
- timestamp=datetime(2020, 1, 2),
- )
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id="user_test_2",
- properties={feature_flag_property: "test", "amount": 75},
- timestamp=datetime(2020, 1, 3),
- )
- _create_event(
- team=self.team,
- event="purchase",
- distinct_id="user_test_3",
- properties={feature_flag_property: "test", "amount": 80},
- timestamp=datetime(2020, 1, 6),
- )
-
- flush_persons_and_events()
-
- prepared_count_query = query_runner.prepared_count_query
- self.assertEqual(prepared_count_query.series[0].math, "sum")
-
- result = query_runner.calculate()
- trend_result = cast(ExperimentTrendsQueryResponse, result)
-
- self.assertEqual(trend_result.significant, False)
- self.assertEqual(trend_result.significance_code, ExperimentSignificanceCode.NOT_ENOUGH_EXPOSURE)
- self.assertEqual(trend_result.p_value, 1.0)
-
- self.assertEqual(len(result.variants), 2)
-
- control_result = next(variant for variant in trend_result.variants if variant.key == "control")
- test_result = next(variant for variant in trend_result.variants if variant.key == "test")
-
- control_insight = next(variant for variant in trend_result.insight if variant["breakdown_value"] == "control")
- test_insight = next(variant for variant in trend_result.insight if variant["breakdown_value"] == "test")
-
- self.assertEqual(control_result.count, 100)
- self.assertAlmostEqual(test_result.count, 205)
- self.assertEqual(control_result.absolute_exposure, 1)
- self.assertEqual(test_result.absolute_exposure, 3)
-
- self.assertEqual(
- control_insight["data"],
- [0.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0],
- )
- self.assertEqual(
- test_insight["data"],
- [0.0, 50.0, 125.0, 125.0, 125.0, 205.0, 205.0, 205.0, 205.0, 205.0, 205.0, 205.0, 205.0, 205.0, 205.0],
- )
-
- @pytest.mark.flaky(reruns=9)
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_query_runner_standard_flow_v2_stats(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
- experiment.save()
-
- ff_property = f"$feature/{feature_flag.key}"
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- journeys_for(
- {
- "user_control_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {"event": "$pageview", "timestamp": "2020-01-03", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {
- "$feature_flag_response": "control",
- ff_property: "control",
- "$feature_flag": feature_flag.key,
- },
- },
- ],
- "user_control_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {
- "$feature_flag_response": "control",
- ff_property: "control",
- "$feature_flag": feature_flag.key,
- },
- },
- ],
- "user_test_1": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-04", "properties": {ff_property: "test"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {
- "$feature_flag_response": "test",
- ff_property: "test",
- "$feature_flag": feature_flag.key,
- },
- },
- ],
- "user_test_2": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- {"event": "$pageview", "timestamp": "2020-01-03", "properties": {ff_property: "test"}},
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {
- "$feature_flag_response": "test",
- ff_property: "test",
- "$feature_flag": feature_flag.key,
- },
- },
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- query_runner = ExperimentTrendsQueryRunner(
- query=ExperimentTrendsQuery(**experiment.metrics[0]["query"]), team=self.team
- )
- result = query_runner.calculate()
-
- self.assertEqual(len(result.variants), 2)
- for variant in result.variants:
- self.assertIn(variant.key, ["control", "test"])
-
- control_variant = next(v for v in result.variants if v.key == "control")
- test_variant = next(v for v in result.variants if v.key == "test")
-
- self.assertEqual(control_variant.count, 3)
- self.assertEqual(test_variant.count, 5)
- self.assertEqual(control_variant.absolute_exposure, 2)
- self.assertEqual(test_variant.absolute_exposure, 2)
-
- self.assertAlmostEqual(result.credible_intervals["control"][0], 0.3633, delta=0.1)
- self.assertAlmostEqual(result.credible_intervals["control"][1], 2.9224, delta=0.1)
- self.assertAlmostEqual(result.credible_intervals["test"][0], 0.7339, delta=0.1)
- self.assertAlmostEqual(result.credible_intervals["test"][1], 3.8894, delta=0.1)
-
- self.assertAlmostEqual(result.p_value, 1.0, delta=0.1)
-
- self.assertAlmostEqual(result.probability["control"], 0.2549, delta=0.1)
- self.assertAlmostEqual(result.probability["test"], 0.7453, delta=0.1)
-
- self.assertEqual(result.significance_code, ExperimentSignificanceCode.NOT_ENOUGH_EXPOSURE)
-
- self.assertFalse(result.significant)
-
- self.assertEqual(len(result.variants), 2)
-
- self.assertEqual(control_variant.absolute_exposure, 2.0)
- self.assertEqual(control_variant.count, 3.0)
- self.assertEqual(control_variant.exposure, 1.0)
-
- self.assertEqual(test_variant.absolute_exposure, 2.0)
- self.assertEqual(test_variant.count, 5.0)
- self.assertEqual(test_variant.exposure, 1.0)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_validate_event_variants_no_control(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- journeys_for(
- {
- "user_test": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- )
-
- query_runner = ExperimentTrendsQueryRunner(query=experiment_query, team=self.team)
- with self.assertRaises(ValidationError) as context:
- query_runner.calculate()
-
- expected_errors = json.dumps(
- {
- ExperimentNoResultsErrorKeys.NO_EXPOSURES: True,
- ExperimentNoResultsErrorKeys.NO_CONTROL_VARIANT: True,
- ExperimentNoResultsErrorKeys.NO_TEST_VARIANT: False,
- }
- )
- self.assertEqual(cast(list, context.exception.detail)[0], expected_errors)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_validate_event_variants_no_test(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
- journeys_for(
- {
- "user_control": [
- {
- "event": "$feature_flag_called",
- "timestamp": "2020-01-02",
- "properties": {
- "$feature_flag_response": "control",
- "$feature_flag": feature_flag.key,
- },
- },
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- )
-
- query_runner = ExperimentTrendsQueryRunner(query=experiment_query, team=self.team)
- with self.assertRaises(ValidationError) as context:
- query_runner.calculate()
-
- expected_errors = json.dumps(
- {
- ExperimentNoResultsErrorKeys.NO_EXPOSURES: False,
- ExperimentNoResultsErrorKeys.NO_CONTROL_VARIANT: False,
- ExperimentNoResultsErrorKeys.NO_TEST_VARIANT: True,
- }
- )
- self.assertEqual(cast(list, context.exception.detail)[0], expected_errors)
-
- @time_machine.travel("2020-01-01T12:00:00Z", tick=False)
- def test_validate_event_variants_no_exposure(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- ff_property = f"$feature/{feature_flag.key}"
-
- journeys_for(
- {
- "user_control": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "control"}},
- ],
- "user_test": [
- {"event": "$pageview", "timestamp": "2020-01-02", "properties": {ff_property: "test"}},
- ],
- },
- self.team,
- )
-
- flush_persons_and_events()
-
- count_query = TrendsQuery(series=[EventsNode(event="$pageview")])
-
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- exposure_query=None,
- )
-
- experiment.metrics = [{"type": "primary", "query": experiment_query.model_dump()}]
- experiment.save()
-
- query_runner = ExperimentTrendsQueryRunner(query=experiment_query, team=self.team)
- with self.assertRaises(ValidationError) as context:
- query_runner.calculate()
-
- expected_errors = json.dumps(
- {
- ExperimentNoResultsErrorKeys.NO_EXPOSURES: True,
- ExperimentNoResultsErrorKeys.NO_CONTROL_VARIANT: False,
- ExperimentNoResultsErrorKeys.NO_TEST_VARIANT: False,
- }
- )
- self.assertEqual(cast(list, context.exception.detail)[0], expected_errors)
-
- def test_get_metric_type(self):
- feature_flag = self.create_feature_flag()
- experiment = self.create_experiment(feature_flag=feature_flag)
-
- # Test allowed count math types
- allowed_count_math_types = [BaseMathType.TOTAL, BaseMathType.DAU, BaseMathType.UNIQUE_SESSION, None]
- for math_type in allowed_count_math_types:
- count_query = TrendsQuery(series=[EventsNode(event="$pageview", math=math_type)])
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- )
- query_runner = ExperimentTrendsQueryRunner(query=experiment_query, team=self.team)
- self.assertEqual(query_runner._get_metric_type(), ExperimentMetricType.COUNT)
-
- # Test allowed sum math types
- allowed_sum_math_types: list[Any] = [PropertyMathType.SUM, "hogql"]
- for math_type in allowed_sum_math_types:
- count_query = TrendsQuery(
- series=[EventsNode(event="checkout completed", math=math_type, math_property="revenue")]
- )
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- )
- query_runner = ExperimentTrendsQueryRunner(query=experiment_query, team=self.team)
- self.assertEqual(query_runner._get_metric_type(), ExperimentMetricType.CONTINUOUS)
-
- # Test that AVG math gets converted to SUM and returns CONTINUOUS
- count_query = TrendsQuery(
- series=[EventsNode(event="checkout completed", math=PropertyMathType.AVG, math_property="revenue")]
- )
- experiment_query = ExperimentTrendsQuery(
- experiment_id=experiment.id,
- kind="ExperimentTrendsQuery",
- count_query=count_query,
- )
- query_runner = ExperimentTrendsQueryRunner(query=experiment_query, team=self.team)
- self.assertEqual(query_runner._get_metric_type(), ExperimentMetricType.CONTINUOUS)
- # Verify the math type was converted to sum
- self.assertEqual(query_runner.query.count_query.series[0].math, PropertyMathType.SUM)
diff --git a/products/experiments/backend/test/test_metric_utils.py b/products/experiments/backend/test/test_metric_utils.py
index c3abc980fc29..7e599762ab92 100644
--- a/products/experiments/backend/test/test_metric_utils.py
+++ b/products/experiments/backend/test/test_metric_utils.py
@@ -8,7 +8,6 @@ from parameterized import parameterized
from products.actions.backend.models.action import Action
from products.experiments.backend.metric_utils import (
- apply_metric_date_range,
collect_metric_events_and_action_ids,
collect_metric_warehouse_tables,
refresh_action_names_in_metric,
@@ -501,23 +500,3 @@ class TestResolveActionEvents(BaseTest):
def test_empty_makes_no_query(self):
with self.assertNumQueries(0):
assert resolve_action_events(set(), self.team) == {}
-
-
-class TestApplyMetricDateRange(SimpleTestCase):
- NEW_RANGE = {"date_from": "2025-02-01T00:00:00Z", "date_to": "", "explicitDate": True}
-
- @parameterized.expand([("trends", "count_query"), ("funnels", "funnels_query")])
- def test_overwrites_a_stale_nested_date_range(self, _name: str, query_key: str) -> None:
- metric = {query_key: {"dateRange": {"date_from": "2025-01-30T12:16", "date_to": "2025-02-13T23:59"}}}
-
- apply_metric_date_range(metric, self.NEW_RANGE)
-
- assert metric[query_key]["dateRange"] == self.NEW_RANGE
-
- @parameterized.expand([("trends", "count_query"), ("funnels", "funnels_query")])
- def test_leaves_a_metric_without_a_date_range_alone(self, _name: str, query_key: str) -> None:
- metric: dict = {query_key: {"series": []}}
-
- apply_metric_date_range(metric, self.NEW_RANGE)
-
- assert metric == {query_key: {"series": []}}
diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.py
index 0dd485cf4876..022661f5a8e7 100644
--- a/products/experiments/backend/test/test_presentation_api.py
+++ b/products/experiments/backend/test/test_presentation_api.py
@@ -67,7 +67,6 @@ from products.feature_flags.backend.models.evaluation_context import EvaluationC
from products.feature_flags.backend.models.feature_flag import FeatureFlag
from ee.api.test.base import APILicensedTest
-from ee.clickhouse.views.experiment_saved_metrics import ExperimentToSavedMetricSerializer
def _make(cls, **attrs):
@@ -1576,90 +1575,6 @@ class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):
self.assertEqual(response.json()["type"], "validation_error")
self.assertEqual(response.json()["detail"], "Metadata must be an object")
- @time_machine.travel("2025-02-10T13:00:00Z", tick=False)
- def test_fetching_experiment_with_stale_metric_dates_applies_experiment_date_range(self):
- test_feature_flag = FeatureFlag.objects.create(
- name=f"Test experiment flag",
- key="test-flag",
- team=self.team,
- filters={
- "groups": [{"properties": [], "rollout_percentage": None}],
- "multivariate": {
- "variants": [
- {
- "key": "control",
- "name": "Control",
- "rollout_percentage": 50,
- },
- {
- "key": "test",
- "name": "Test",
- "rollout_percentage": 50,
- },
- ]
- },
- },
- created_by=self.user,
- )
- trends_query = {
- "kind": "ExperimentTrendsQuery",
- "count_query": {
- "kind": "TrendsQuery",
- "series": [
- {
- "kind": "EventsNode",
- "math": "total",
- "name": "[jan-16-running] event one",
- "event": "[jan-16-running] event one",
- }
- ],
- "interval": "day",
- "dateRange": {"date_to": "2025-01-16T23:59", "date_from": "2025-01-02T13:54", "explicitDate": True},
- "trendsFilter": {"display": "ActionsLineGraph"},
- "filterTestAccounts": True,
- },
- }
- saved_trends_metric = ExperimentSavedMetric.objects.create(
- name="Test saved metric",
- description="Test description",
- query=trends_query,
- team=self.team,
- created_by=self.user,
- )
- experiment = Experiment.objects.create(
- name="Test Experiment with stale dates",
- team=self.team,
- feature_flag=test_feature_flag,
- start_date=datetime(2025, 2, 1),
- end_date=None,
- metrics=[trends_query],
- metrics_secondary=[trends_query],
- )
-
- saved_metric_serializer = ExperimentToSavedMetricSerializer(
- data={
- "experiment": experiment.id,
- "saved_metric": saved_trends_metric.id,
- "metadata": {"type": "secondary"},
- },
- )
- saved_metric_serializer.is_valid(raise_exception=True)
- saved_metric_serializer.save()
-
- response = self.client.get(f"/api/projects/{self.team.id}/experiments/{experiment.id}")
- self.assertEqual(response.status_code, status.HTTP_200_OK)
- self.assertEqual(response.json()["metrics"][0]["count_query"]["dateRange"]["date_from"], "2025-02-01T00:00:00Z")
- self.assertEqual(response.json()["metrics"][0]["count_query"]["dateRange"]["date_to"], "")
- self.assertEqual(
- response.json()["metrics_secondary"][0]["count_query"]["dateRange"]["date_from"], "2025-02-01T00:00:00Z"
- )
- self.assertEqual(response.json()["metrics_secondary"][0]["count_query"]["dateRange"]["date_to"], "")
- self.assertEqual(
- response.json()["saved_metrics"][0]["query"]["count_query"]["dateRange"]["date_from"],
- "2025-02-01T00:00:00Z",
- )
- self.assertEqual(response.json()["saved_metrics"][0]["query"]["count_query"]["dateRange"]["date_to"], "")
-
def test_adding_behavioral_cohort_filter_to_experiment_fails(self):
cohort = Cohort.objects.create(
team=self.team,
diff --git a/products/experiments/frontend/legacy/calculations/legacyExperimentCalculations.test.tsx b/products/experiments/frontend/legacy/calculations/legacyExperimentCalculations.test.tsx
deleted file mode 100644
index 9715536f2888..000000000000
--- a/products/experiments/frontend/legacy/calculations/legacyExperimentCalculations.test.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import {
- legacyExpectedRunningTime,
- legacyMinimumSampleSizePerVariant,
- legacyRecommendedExposureForCountData,
-} from './legacyExperimentCalculations'
-
-describe('experimentCalculations', () => {
- describe('minimumSampleSizePerVariant', () => {
- it('given an mde, calculates correct sample size', () => {
- // Using the rule of thumb: sampleSize = 16 * sigma^2 / (mde^2)
- expect(legacyMinimumSampleSizePerVariant(30, 20)).toEqual(29)
-
- expect(legacyMinimumSampleSizePerVariant(30, 40)).toEqual(43)
-
- expect(legacyMinimumSampleSizePerVariant(30, 0)).toEqual(0)
- })
- })
-
- describe('expectedRunningTime', () => {
- it('given sample size and entrants, calculates correct running time', () => {
- // 500 entrants over 14 days, 1000 sample size, so need twice the time
- expect(legacyExpectedRunningTime(500, 1000)).toEqual(28)
-
- // 500 entrants over 14 days, 250 sample size, so need half the time
- expect(legacyExpectedRunningTime(500, 250)).toEqual(7)
-
- // 0 entrants over 14 days, so infinite running time
- expect(legacyExpectedRunningTime(0, 1000)).toEqual(Infinity)
-
- // Custom duration
- expect(legacyExpectedRunningTime(500, 1000, 7)).toEqual(14)
- })
- })
-
- describe('recommendedExposureForCountData', () => {
- it('given control count data, calculates correct exposure time', () => {
- // Using formula: 4 / (sqrt(lambda1/days) - sqrt(lambda2/days))^2
-
- // 1000 count over 14 days
- expect(legacyRecommendedExposureForCountData(30, 1000)).toEqual(2.8)
-
- // 10,000 count over 14 days - 10x count, so 1/10th running time
- expect(legacyRecommendedExposureForCountData(30, 10000)).toEqual(0.3)
-
- // 0 count, so should be Infinity (can't calculate with zero)
- expect(legacyRecommendedExposureForCountData(30, 0)).toEqual(Infinity)
- })
- })
-})
diff --git a/products/experiments/frontend/legacy/metricsView/legacyViolinUtils.test.ts b/products/experiments/frontend/legacy/metricsView/legacyViolinUtils.test.ts
deleted file mode 100644
index c71f400cab59..000000000000
--- a/products/experiments/frontend/legacy/metricsView/legacyViolinUtils.test.ts
+++ /dev/null
@@ -1,158 +0,0 @@
-import { legacyGenerateViolinPath } from './legacyViolinUtils'
-
-/**
- * @deprecated
- * Legacy violin plot utility function test.
- * Frozen copy for legacy experiments - do not modify.
- */
-
-/**
- * Helper function to parse SVG path string into points, optionally skipping the initial move command
- */
-function parseSvgPathToPoints(path: string, skipInitialMove = false): Array<{ x: number; y: number }> {
- // Clean up the path string by removing newlines and extra spaces
- const cleanPath = path.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim()
- const points: Array<{ x: number; y: number }> = []
- let firstPoint = true
- const parts = cleanPath.split(' ')
-
- for (let i = 0; i < parts.length; i++) {
- const part = parts[i]
- if (part === 'M' || part === 'L') {
- // These commands are followed by x,y coordinates
- const x = Number(parts[i + 1])
- const y = Number(parts[i + 2])
- if (!isNaN(x) && !isNaN(y)) {
- // Skip the first point if it's from the M command and skipInitialMove is true
- if (!(skipInitialMove && firstPoint && part === 'M')) {
- points.push({ x, y })
- }
- firstPoint = false
- }
- i += 2 // Skip the coordinates we just processed
- }
- // Skip 'Z' as it doesn't have coordinates
- }
-
- return points
-}
-
-describe('legacyGenerateViolinPath', () => {
- it('generates a valid SVG path string', () => {
- const x1 = 10
- const x2 = 30
- const y = 5
- const height = 10
- const deltaX = 20
-
- const path = legacyGenerateViolinPath(x1, x2, y, height, deltaX)
-
- // Check that the path is a valid SVG path string
- expect(typeof path).toBe('string')
- expect(path).toContain('M') // Should start with a move command
- expect(path).toContain('L') // Should contain line commands
- expect(path).toContain('Z') // Should end with a close path command
- })
-
- it('generates a symmetric path', () => {
- const x1 = 0
- const x2 = 100
- const y = 50
- const height = 20
- const deltaX = 50
-
- const path = legacyGenerateViolinPath(x1, x2, y, height, deltaX)
- const points = parseSvgPathToPoints(path, true)
-
- // Check vertical symmetry around deltaX, excluding points exactly at deltaX
- const leftPoints = points.filter((p) => p.x < deltaX)
- const rightPoints = points.filter((p) => p.x > deltaX)
- const centerPoints = points.filter((p) => p.x === deltaX)
-
- expect(leftPoints.length).toBe(rightPoints.length)
- // Verify that points at deltaX come in pairs (top and bottom of violin)
- expect(centerPoints.length % 2).toBe(0)
- })
-
- it('generates an asymmetric path when deltaX is not centered', () => {
- const x1 = 0
- const x2 = 100
- const y = 50
- const height = 20
- const deltaX = 30 // Asymmetric - closer to x1 than x2
-
- const path = legacyGenerateViolinPath(x1, x2, y, height, deltaX)
- const points = parseSvgPathToPoints(path, true)
-
- // Check points on each side of deltaX
- const leftPoints = points.filter((p) => p.x < deltaX)
- const rightPoints = points.filter((p) => p.x > deltaX)
- const centerPoints = points.filter((p) => p.x === deltaX)
-
- // Should still have equal number of points on each side
- expect(leftPoints.length).toBe(rightPoints.length)
- expect(centerPoints.length % 2).toBe(0)
-
- // But the x-coordinates should be distributed differently
- const leftSpan = deltaX - x1
- const rightSpan = x2 - deltaX
- expect(rightSpan).toBeGreaterThan(leftSpan)
-
- // Check that points are distributed proportionally
- const leftStep = leftSpan / (leftPoints.length / 2) // divide by 2 because points appear in pairs (top/bottom)
- const rightStep = rightSpan / (rightPoints.length / 2)
- expect(rightStep).toBeGreaterThan(leftStep)
- })
-
- it('respects the height parameter', () => {
- const x1 = 0
- const x2 = 100
- const y = 50
- const height = 20
- const deltaX = 50
-
- const path = legacyGenerateViolinPath(x1, x2, y, height, deltaX)
- const points = parseSvgPathToPoints(path, true)
-
- // Get all y-coordinates from the points
- const yCoords = points.map((p) => p.y)
-
- // Check that all y-coordinates are within the specified height range
- const minY = Math.min(...yCoords)
- const maxY = Math.max(...yCoords)
-
- expect(maxY - minY).toBeLessThanOrEqual(height)
- expect(minY).toBeGreaterThanOrEqual(y)
- expect(maxY).toBeLessThanOrEqual(y + height)
- })
-
- it('handles zero height gracefully', () => {
- const x1 = 0
- const x2 = 100
- const y = 50
- const height = 0
- const deltaX = 50
-
- const path = legacyGenerateViolinPath(x1, x2, y, height, deltaX)
-
- // Should still return a valid path string
- expect(typeof path).toBe('string')
- expect(path).toContain('M')
- expect(path).toContain('Z')
- })
-
- it('handles equal x1 and x2 gracefully', () => {
- const x1 = 50
- const x2 = 50
- const y = 50
- const height = 20
- const deltaX = 50
-
- const path = legacyGenerateViolinPath(x1, x2, y, height, deltaX)
-
- // Should still return a valid path string
- expect(typeof path).toBe('string')
- expect(path).toContain('M')
- expect(path).toContain('Z')
- })
-})
diff --git a/products/model_crossing_uses_baseline.txt b/products/model_crossing_uses_baseline.txt
index 8f60da2beaf3..a0d5b3c02713 100644
--- a/products/model_crossing_uses_baseline.txt
+++ b/products/model_crossing_uses_baseline.txt
@@ -652,7 +652,6 @@ product_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_i
product_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_materialization_suggestion drives(TrendsQuery) 1
product_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_openapi_spec drives(TrendsQuery) 4
product_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_variable_materialization drives(TrendsQuery) 1
-product_analytics:backend/hogql_queries/ products.experiments.backend.test.test_presentation_api drives(TrendsQuery) 1
product_analytics:backend/hogql_queries/ products.feature_flags.backend.api.test.test_feature_flag drives(TrendsQuery) 6
product_analytics:backend/hogql_queries/ products.posthog_ai.scripts.hogql_example.test.test_hogql_example drives(TrendsQuery) 3
product_analytics:backend/hogql_queries/ products.signals.backend.test.test_scout_report_api drives(TrendsQuery) 1
@@ -979,7 +978,6 @@ web_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_insig
web_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_materialization_suggestion drives(TrendsQuery) 1
web_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_openapi_spec drives(TrendsQuery) 4
web_analytics:backend/hogql_queries/ products.endpoints.backend.tests.test_variable_materialization drives(TrendsQuery) 1
-web_analytics:backend/hogql_queries/ products.experiments.backend.test.test_presentation_api drives(TrendsQuery) 1
web_analytics:backend/hogql_queries/ products.feature_flags.backend.api.test.test_feature_flag drives(TrendsQuery) 6
web_analytics:backend/hogql_queries/ products.posthog_ai.scripts.hogql_example.test.test_hogql_example drives(TrendsQuery) 3
web_analytics:backend/hogql_queries/ products.product_analytics.backend.hogql_queries.trends.test.test_trends_data_warehouse_query drives(TrendsQuery) 23